From d74180c373274bc545992c2a96a8e7618f8bd52c Mon Sep 17 00:00:00 2001 From: Carl Ã…stholm Date: Sun, 2 Jun 2024 18:11:16 +0200 Subject: Replace YES_COLOR with CLICOLOR_FORCE Instead of introducing YES_COLOR, a completely new standard, into the mix it might make more sense to instead tag along with the CLICOLOR_FORCE env var, which dates back to at least 2000 with FreeBSD 4.1.1 and which is supported by tools like CMake. --- src/main.zig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 7e00b8c058..21f7281d74 100644 --- a/src/main.zig +++ b/src/main.zig @@ -994,11 +994,16 @@ fn buildOutputType( .native_system_include_paths = &.{}, }; - // before arg parsing, check for the NO_COLOR environment variable - // if it exists, default the color setting to .off + // before arg parsing, check for the NO_COLOR and CLICOLOR_FORCE environment variables + // if set, default the color setting to .off or .on, respectively // explicit --color arguments will still override this setting. // Disable color on WASI per https://github.com/WebAssembly/WASI/issues/162 - var color: Color = if (native_os == .wasi or EnvVar.NO_COLOR.isSet()) .off else .auto; + var color: Color = if (native_os == .wasi or EnvVar.NO_COLOR.isSet()) + .off + else if (EnvVar.CLICOLOR_FORCE.isSet()) + .on + else + .auto; switch (arg_mode) { .build, .translate_c, .zig_test, .run => { -- cgit v1.2.3