Re-use DEFAULT_PATH in setup_path

- No need to hard-code a different default
This commit is contained in:
Henrik Hørlück Berg 2023-08-20 16:08:54 +02:00 committed by Fabian Boehm
parent 008764a2cd
commit 676c3c9bc2
3 changed files with 4 additions and 3 deletions

View file

@ -512,7 +512,7 @@ fn setup_path() {
str2wcstring(cstr.to_bytes())
} else {
// the above should really not fail
L!("/usr/bin:/bin").to_owned()
join_strings(crate::path::DEFAULT_PATH.as_ref(), ':')
};
vars.set_one(L!("PATH"), EnvMode::GLOBAL | EnvMode::EXPORT, path);

View file

@ -185,7 +185,7 @@ pub fn path_get_path(cmd: &wstr, vars: &dyn Environment) -> Option<WString> {
// PREFIX is defined at build time.
#[widestrs]
static DEFAULT_PATH: Lazy<[WString; 3]> = Lazy::new(|| {
pub static DEFAULT_PATH: Lazy<[WString; 3]> = Lazy::new(|| {
[
// TODO This should use env!. The fallback is only to appease "cargo test" for now.
WString::from_str(option_env!("PREFIX").unwrap_or("/usr/local")) + "/bin"L,

View file

@ -6,6 +6,7 @@ if command -q getconf
env -u PATH $fish -c 'test "$PATH" = "$('(command -s getconf)' PATH)"; and echo Success'
else
# this is DEFAULT_PATH
env -u PATH $fish -c 'test "$PATH" = "/usr/bin:/bin"; and echo Success'
# the first element (usually `/usr/local/bin`) depends on PREFIX set in CMake, so we ignore it
env -u PATH $fish -c 'test "$PATH[2..]" = "/usr/bin:/bin"; and echo Success'
end
# CHECK: Success