diff --git a/src/os/env.zig b/src/os/env.zig index b9ebcc9c8..b40d2fef1 100644 --- a/src/os/env.zig +++ b/src/os/env.zig @@ -24,6 +24,9 @@ pub fn appendEnv( } /// Always append value to environment, even when it is empty. +/// This is useful because some env vars (like MANPATH) want there +/// to be an empty prefix to preserve existing values. +/// /// The returned value is always allocated so it must be freed. pub fn appendEnvAlways( alloc: Allocator, diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 69c139563..ac6bff7b7 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -648,13 +648,16 @@ const Subprocess = struct { break :man; }; - const manpath = env.get("MANPATH") orelse ""; // Always append with colon in front, as it mean that if // `MANPATH` is empty, then it should be treated as an extra // path instead of overriding all paths set by OS. try env.put( "MANPATH", - try internal_os.appendEnvAlways(alloc, manpath, dir), + try internal_os.appendEnvAlways( + alloc, + env.get("MATHPATH") orelse "", + dir, + ), ); } }