This commit is contained in:
Mitchell Hashimoto
2024-07-18 15:57:55 -07:00
parent 255e50124c
commit 1100145cf3
2 changed files with 8 additions and 2 deletions

View File

@ -24,6 +24,9 @@ pub fn appendEnv(
} }
/// Always append value to environment, even when it is empty. /// 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. /// The returned value is always allocated so it must be freed.
pub fn appendEnvAlways( pub fn appendEnvAlways(
alloc: Allocator, alloc: Allocator,

View File

@ -648,13 +648,16 @@ const Subprocess = struct {
break :man; break :man;
}; };
const manpath = env.get("MANPATH") orelse "";
// Always append with colon in front, as it mean that if // Always append with colon in front, as it mean that if
// `MANPATH` is empty, then it should be treated as an extra // `MANPATH` is empty, then it should be treated as an extra
// path instead of overriding all paths set by OS. // path instead of overriding all paths set by OS.
try env.put( try env.put(
"MANPATH", "MANPATH",
try internal_os.appendEnvAlways(alloc, manpath, dir), try internal_os.appendEnvAlways(
alloc,
env.get("MATHPATH") orelse "",
dir,
),
); );
} }
} }