enum EnvVar [src]
Collects all the environment variables that Zig could possibly inspect, so
that we can do reflection on this and print them with zig env.
Fields
ZIG_GLOBAL_CACHE_DIR
ZIG_LOCAL_CACHE_DIR
ZIG_LIB_DIR
ZIG_LIBC
ZIG_BUILD_RUNNER
ZIG_VERBOSE_LINK
ZIG_VERBOSE_CC
ZIG_BTRFS_WORKAROUND
ZIG_DEBUG_CMD
CC
NO_COLOR
CLICOLOR_FORCE
XDG_CACHE_HOME
HOME
Members
Source
pub const EnvVar = enum {
ZIG_GLOBAL_CACHE_DIR,
ZIG_LOCAL_CACHE_DIR,
ZIG_LIB_DIR,
ZIG_LIBC,
ZIG_BUILD_RUNNER,
ZIG_VERBOSE_LINK,
ZIG_VERBOSE_CC,
ZIG_BTRFS_WORKAROUND,
ZIG_DEBUG_CMD,
CC,
NO_COLOR,
CLICOLOR_FORCE,
XDG_CACHE_HOME,
HOME,
pub fn isSet(comptime ev: EnvVar) bool {
return std.process.hasNonEmptyEnvVarConstant(@tagName(ev));
}
pub fn get(ev: EnvVar, arena: std.mem.Allocator) !?[]u8 {
if (std.process.getEnvVarOwned(arena, @tagName(ev))) |value| {
return value;
} else |err| switch (err) {
error.EnvironmentVariableNotFound => return null,
else => |e| return e,
}
}
pub fn getPosix(comptime ev: EnvVar) ?[:0]const u8 {
return std.posix.getenvZ(@tagName(ev));
}
}