Skip to content

Commit

Permalink
Re-use DEFAULT_PATH in setup_path
Browse files Browse the repository at this point in the history
- No need to hard-code a different default
  • Loading branch information
henrikhorluck committed Aug 21, 2023
1 parent bb26941 commit 45c811c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fish-rust/src/env/environment.rs
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion fish-rust/src/path.rs
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/checks/default-setup-path.fish
Expand Up @@ -5,8 +5,8 @@
if command -q getconf
env -u PATH $fish -c 'test "$PATH" = "$('(command -s getconf)' PATH)"; and echo Success'
else
# this is our DEFAULT_PATH
# this is DEFAULT_PATH
# This techinically depends on PREFIX set in CMake
env -u PATH $fish -c 'test "$PATH" = "/usr/bin:/bin"; and echo Success'
env -u PATH $fish -c 'test "$PATH" = "/usr/local/bin:/usr/bin:/bin"; and echo Success'
end
# CHECK: Success

0 comments on commit 45c811c

Please sign in to comment.