Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(windows): fix env var glob casing (#9429)
### Description In #9424 a user had `path` as their Windows env var instead of `Path` or `PATH`. On Windows environment variables are case insensitive e.g. `process.env.PATH` and `process.env.Path` would both return the same. While fetching them might be the same [`std::env::vars`](https://doc.rust-lang.org/std/env/fn.vars.html) returns the environment variable names cased as they were declared even though [`std::env::var`](https://doc.rust-lang.org/std/env/fn.var.html) is case insensitive on Windows. Take for example the following code: ``` for (key, value) in std::env::vars() { println!("{key}: {value}"); let lowercase = key.to_ascii_lowercase(); println!("{lowercase}: {:?}", std::env::var(&lowercase)); } ``` On Windows it outputs: ``` ... PUBLIC: C:\Users\Public public: Ok("C:\\Users\\Public") SESSIONNAME: Console sessionname: Ok("Console") SystemDrive: C: systemdrive: Ok("C:") SystemRoot: C:\WINDOWS systemroot: Ok("C:\\WINDOWS") TEMP: C:\Users\Chris\AppData\Local\Temp temp: Ok("C:\\Users\\Chris\\AppData\\Local\\Temp") TMP: C:\Users\Chris\AppData\Local\Temp tmp: Ok("C:\\Users\\Chris\\AppData\\Local\\Temp") ``` On macOs it outputs: ``` ... TMPDIR: /var/folders/3m/rxkycvgs5jgfvs0k9xcgp6km0000gn/T/ tmpdir: Err(NotPresent) TMUX: /private/tmp/tmux-501/default,3104,0 tmux: Err(NotPresent) TMUX_PANE: %4 tmux_pane: Err(NotPresent) USER: olszewski user: Err(NotPresent) USER_ZDOTDIR: /Users/olszewski user_zdotdir: Err(NotPresent) ``` Previously we had special casing for well known Windows env vars that were set differently between Command Prompt and Powershell, but would break if a user overwrote `Path` or `PATH` to `path`. This was brittle and a correct solution would require that we include all casing variations of all environment variables and users would also need to know how env vars were declared on their Windows system. This fix is to make our env var wildcard handling case in ### Testing Instructions Added unit test to make sure we
- Loading branch information