From 5a01181f8f2bb03dc02df1e63667b1ee921138b2 Mon Sep 17 00:00:00 2001 From: Rauli Laine Date: Fri, 6 Feb 2026 18:13:58 +0100 Subject: [PATCH] Disable colors if NO_COLOR env var is present and nonempty Disable colors when environment variable `NO_COLOR` is present and nonempty, according to the "standard" described in http://no-color.org/ The command line option --color may override this. Signed-off-by: Egmont Koblinger --- src/args.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/args.c b/src/args.c index c76d25a20..399d353c9 100644 --- a/src/args.c +++ b/src/args.c @@ -612,11 +612,17 @@ mc_setup_run_mode (char **argv) gboolean mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError **mcerror) { + const char *nocolor_env; const gchar *_system_codepage; gboolean ok = TRUE; mc_return_val_if_error (mcerror, FALSE); + // https://no-color.org/ - avoid colors if NO_COLOR is nonempty, unless overridden in cmdline + nocolor_env = getenv ("NO_COLOR"); + if (nocolor_env != NULL && nocolor_env[0] != '\0') + mc_global.tty.disable_colors = TRUE; + _system_codepage = str_detect_termencoding (); #ifdef ENABLE_NLS