From a15d14e038d7493e82444c8c42fd3db45ea9ff40 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 25 Apr 2020 15:10:34 +0200 Subject: [PATCH 1/2] Make sure colors and emoji are disabled when not on TTY --- client/src/fileutils.c | 2 +- client/src/proxmark3.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/fileutils.c b/client/src/fileutils.c index 936bf0aef..4d1b8355d 100644 --- a/client/src/fileutils.c +++ b/client/src/fileutils.c @@ -986,10 +986,10 @@ int loadFileJSON(const char *preferredName, void *data, size_t maxdatalen, size_ } *datalen = sptr; } + PrintAndLogEx(SUCCESS, "loaded from JSON file " _YELLOW_("%s"), fileName); if (!strcmp(ctype, "settings")) { preferences_load_callback(root); } - PrintAndLogEx(SUCCESS, "loaded from JSON file " _YELLOW_("%s"), fileName); out: json_decref(root); free(fileName); diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 730504714..0cd545389 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -908,6 +908,12 @@ int main(int argc, char *argv[]) { session.supports_colors = true; session.emoji_mode = EMOJI; } + } else { + // even if prefs, we disable colors if stdin or stdout is not a TTY + if ((! session.stdinOnTTY) || (! session.stdoutOnTTY)) { + session.supports_colors = false; + session.emoji_mode = ALTTEXT; + } } #else if (session.stdinOnTTY && session.stdoutOnTTY) { From ae21a3148f5ca54ea2a5c75a8f54832700f84db5 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 25 Apr 2020 15:17:11 +0200 Subject: [PATCH 2/2] Lighter msg for loading prefs, json will anyway always tell the filename --- client/src/preferences.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/preferences.c b/client/src/preferences.c index 3bc7158b4..f93305b4d 100644 --- a/client/src/preferences.c +++ b/client/src/preferences.c @@ -96,7 +96,7 @@ int preferences_load(void) { // to better control json cant find file error msg. if (fileExists(prefGetFilename())) { - PrintAndLogEx(INFO, "Loading Preferences %s",prefGetFilename()); + PrintAndLogEx(INFO, "Loading Preferences..."); if (loadFileJSON(prefGetFilename(), &dummyData, sizeof(dummyData), &dummyDL) == PM3_SUCCESS) { session.preferences_loaded = true; } @@ -114,7 +114,7 @@ int preferences_save(void) { char *backupFilename = NULL;// [FILENAME_MAX+sizeof(preferencesFilename)+10] = {0}; int fnLen = 0; - PrintAndLogEx(INFO, "Saving preferences ..."); + PrintAndLogEx(INFO, "Saving Preferences..."); fnLen = strlen(prefGetFilename()) + 5; // .bak\0 backupFilename = (char *)calloc(fnLen, sizeof(uint8_t));