if cfg\!(windows) { ... } else { ... } not very compatible, rollback to #[cfg(windows)] ... #[cfg(not(windows))] ...

This commit is contained in:
Zhenping Zhao 2024-12-15 14:22:53 -08:00
parent 4497b698ee
commit 3e17077679
2 changed files with 10 additions and 4 deletions

View file

@ -694,11 +694,14 @@ pub fn is_automatic_env_var(var: &str, ignore_case: bool) -> bool {
let names = AUTOMATIC_ENV_VAR_NAMES.get_or_init(|| {
let base_names = vec!["PWD".into(), "FILE_PWD".into(), "CURRENT_FILE".into()];
if cfg!(windows) {
#[cfg(windows)]
{
let mut extended_names = base_names;
extend_automatic_env_vars(&mut extended_names);
extended_names
} else {
}
#[cfg(not(windows))]
{
base_names
}
});

View file

@ -768,9 +768,12 @@ impl Stack {
let path = nu_path::strip_trailing_slash(path);
let value = Value::string(path.to_string_lossy(), Span::unknown());
self.add_env_var("PWD".into(), value);
if cfg!(windows) {
#[cfg(windows)]
{
fetch_result(self)
} else {
}
#[cfg(not(windows))]
{
Ok(())
}
}