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:
Johannes Altmanninger
2023-09-23 10:35:54 +02:00
parent 48ce8f8721
commit c7c0bb9bb2

View File

@@ -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('/');
}