Commit d74180c373
Changed files (6)
lib
compiler
src
test
tools
lib/compiler/build_runner.zig
@@ -285,7 +285,7 @@ pub fn main() !void {
const ttyconf = get_tty_conf(color, stderr);
switch (ttyconf) {
.no_color => try graph.env_map.put("NO_COLOR", "1"),
- .escape_codes => try graph.env_map.put("YES_COLOR", "1"),
+ .escape_codes => try graph.env_map.put("CLICOLOR_FORCE", "1"),
.windows_api => {},
}
lib/std/io/tty.zig
@@ -7,13 +7,13 @@ const native_os = builtin.os.tag;
/// Detect suitable TTY configuration options for the given file (commonly stdout/stderr).
/// This includes feature checks for ANSI escape codes and the Windows console API, as well as
-/// respecting the `NO_COLOR` and `YES_COLOR` environment variables to override the default.
+/// respecting the `NO_COLOR` and `CLICOLOR_FORCE` environment variables to override the default.
pub fn detectConfig(file: File) Config {
const force_color: ?bool = if (builtin.os.tag == .wasi)
null // wasi does not support environment variables
else if (process.hasEnvVarConstant("NO_COLOR"))
false
- else if (process.hasEnvVarConstant("YES_COLOR"))
+ else if (process.hasEnvVarConstant("CLICOLOR_FORCE"))
true
else
null;
lib/std/zig.zig
@@ -1060,6 +1060,7 @@ pub const EnvVar = enum {
ZIG_DEBUG_CMD,
CC,
NO_COLOR,
+ CLICOLOR_FORCE,
XDG_CACHE_HOME,
HOME,
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 => {
test/src/StackTrace.zig
@@ -61,7 +61,7 @@ fn addExpect(
});
const run = b.addRunArtifact(exe);
- run.removeEnvironmentVariable("YES_COLOR");
+ run.removeEnvironmentVariable("CLICOLOR_FORCE");
run.setEnvironmentVariable("NO_COLOR", "1");
run.expectExitCode(1);
run.expectStdOutEqual("");
tools/doctest.zig
@@ -104,7 +104,7 @@ fn printOutput(
tmp_dir_path: []const u8,
) !void {
var env_map = try process.getEnvMap(arena);
- try env_map.put("YES_COLOR", "1");
+ try env_map.put("CLICOLOR_FORCE", "1");
const host = try std.zig.system.resolveTargetQuery(.{});
const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch);