Compare commits

...

1 Commits

Author SHA1 Message Date
David Wiesen
fcf6cfb311 Preserve core Windows shell environment vars 2026-04-16 20:26:24 -07:00
2 changed files with 35 additions and 1 deletions

View File

@@ -117,7 +117,25 @@ where
const COMMON_CORE_VARS: &[&str] = &["PATH", "SHELL", "TMPDIR", "TEMP", "TMP"];
#[cfg(target_os = "windows")]
const PLATFORM_CORE_VARS: &[&str] = &["PATHEXT", "USERNAME", "USERPROFILE"];
const PLATFORM_CORE_VARS: &[&str] = &[
"APPDATA",
"COMMONPROGRAMFILES",
"COMMONPROGRAMFILES(X86)",
"COMMONPROGRAMW6432",
"COMSPEC",
"HOME",
"HOMEDRIVE",
"HOMEPATH",
"LOCALAPPDATA",
"PATHEXT",
"PROGRAMDATA",
"PROGRAMFILES",
"PROGRAMFILES(X86)",
"PROGRAMW6432",
"SYSTEMROOT",
"USERNAME",
"USERPROFILE",
];
#[cfg(unix)]
const PLATFORM_CORE_VARS: &[&str] = &["HOME", "LANG", "LC_ALL", "LC_CTYPE", "LOGNAME", "USER"];

View File

@@ -171,8 +171,16 @@ fn test_inherit_all_with_default_excludes() {
#[cfg(target_os = "windows")]
fn test_core_inherit_respects_case_insensitive_names_on_windows() {
let vars = make_vars(&[
("AppData", "C:\\Users\\alice\\AppData\\Roaming"),
("ComSpec", "C:\\Windows\\System32\\cmd.exe"),
("HomeDrive", "C:"),
("HomePath", "\\Users\\alice"),
("LOCALAPPDATA", "C:\\Users\\alice\\AppData\\Local"),
("Path", "C:\\Windows\\System32"),
("PathExt", ".COM;.EXE;.BAT;.CMD"),
("ProgramFiles", "C:\\Program Files"),
("ProgramFiles(x86)", "C:\\Program Files (x86)"),
("SystemRoot", "C:\\Windows"),
("TEMP", "C:\\Temp"),
("FOO", "bar"),
]);
@@ -186,8 +194,16 @@ fn test_core_inherit_respects_case_insensitive_names_on_windows() {
let thread_id = ThreadId::new();
let result = populate_env(vars, &policy, Some(thread_id));
let mut expected: HashMap<String, String> = hashmap! {
"AppData".to_string() => "C:\\Users\\alice\\AppData\\Roaming".to_string(),
"ComSpec".to_string() => "C:\\Windows\\System32\\cmd.exe".to_string(),
"HomeDrive".to_string() => "C:".to_string(),
"HomePath".to_string() => "\\Users\\alice".to_string(),
"LOCALAPPDATA".to_string() => "C:\\Users\\alice\\AppData\\Local".to_string(),
"Path".to_string() => "C:\\Windows\\System32".to_string(),
"PathExt".to_string() => ".COM;.EXE;.BAT;.CMD".to_string(),
"ProgramFiles".to_string() => "C:\\Program Files".to_string(),
"ProgramFiles(x86)".to_string() => "C:\\Program Files (x86)".to_string(),
"SystemRoot".to_string() => "C:\\Windows".to_string(),
"TEMP".to_string() => "C:\\Temp".to_string(),
};
expected.insert(CODEX_THREAD_ID_ENV_VAR.to_string(), thread_id.to_string());