Zig 0.16: env

This commit is contained in:
LN Liberda 2026-05-23 03:49:46 +02:00
parent 90b590332b
commit 9b8e88c96d
2 changed files with 5 additions and 5 deletions

View file

@ -608,10 +608,8 @@ pub fn main(init: std.process.Init) void {
browser.loadDir(0);
},
.shell => {
const shell = std.posix.getenvZ("NCDU_SHELL") orelse std.posix.getenvZ("SHELL") orelse "/bin/sh";
var env = std.process.getEnvMap(allocator) catch unreachable;
defer env.deinit();
ui.runCmd(&.{shell}, browser.dir_path, &env, false);
const shell = environ_map.get("NCDU_SHELL") orelse environ_map.get("SHELL") orelse "/bin/sh";
ui.runCmd(&.{shell}, browser.dir_path, false);
state = .browse;
},
.delete => {

View file

@ -649,9 +649,11 @@ fn waitInput() void {
}
}
pub fn runCmd(cmd: []const []const u8, cwd: ?[]const u8, env: *std.process.EnvMap, reporterr: bool) void {
pub fn runCmd(cmd: []const []const u8, cwd: ?[]const u8, reporterr: bool) void {
deinit();
defer init();
var env = main.environ_map.clone(main.allocator) catch unreachable;
defer env.deinit();
// NCDU_LEVEL can only count to 9, keeps the implementation simple.
if (env.get("NCDU_LEVEL")) |l|