mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 04:41:14 -03:00
env: fix boolean sense in get_pwd_slash()
get_pwd_slash() uses "if var.is_empty()" but it should be "if !var.is_empty()". This wasn't a problem so far because in practice most code paths use the get_pwd_slash() override from EnvStackImpl. The generic one is used in the upcoming unit tests.
This commit is contained in:
7
fish-rust/src/env/environment.rs
vendored
7
fish-rust/src/env/environment.rs
vendored
@@ -70,13 +70,10 @@ fn get(&self, name: &wstr) -> Option<EnvVar> {
|
||||
fn get_pwd_slash(&self) -> WString {
|
||||
// Return "/" if PWD is missing.
|
||||
// See https://github.com/fish-shell/fish-shell/issues/5080
|
||||
let Some(var) = self.get(L!("PWD")) else {
|
||||
let Some(var) = self.get_unless_empty(L!("PWD")) else {
|
||||
return WString::from("/");
|
||||
};
|
||||
let mut pwd = WString::new();
|
||||
if var.is_empty() {
|
||||
pwd = var.as_string();
|
||||
}
|
||||
let mut pwd = var.as_string();
|
||||
if !pwd.ends_with('/') {
|
||||
pwd.push('/');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user