From c7c0bb9bb2d1425419dc43c9fdf5a09af35a679a Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 23 Sep 2023 10:35:54 +0200 Subject: [PATCH] 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. --- fish-rust/src/env/environment.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fish-rust/src/env/environment.rs b/fish-rust/src/env/environment.rs index 3e75cd0fa..ae323e2d3 100644 --- a/fish-rust/src/env/environment.rs +++ b/fish-rust/src/env/environment.rs @@ -70,13 +70,10 @@ fn get(&self, name: &wstr) -> Option { 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('/'); }