mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 12:21:19 -03:00
Allow set --query to check for pathvarness (#8494)
Currently,
set -q --unpath PATH
simply ignores the "--unpath" bit (and same for "--path").
This changes it, so just like exportedness you can check pathness.
This commit is contained in:
12
src/env.cpp
12
src/env.cpp
@@ -509,6 +509,14 @@ struct query_t {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool pathvar_matches(const env_var_t &var) const {
|
||||
if (has_pathvar_unpathvar) {
|
||||
return var.is_pathvar() ? pathvar : unpathvar;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Struct representing one level in the function variable stack.
|
||||
@@ -804,6 +812,10 @@ maybe_t<env_var_t> env_scoped_impl_t::get(const wcstring &key, env_mode_flags_t
|
||||
if (result && !query.export_matches(*result)) {
|
||||
result = none();
|
||||
}
|
||||
// Same for pathvars
|
||||
if (result && !query.pathvar_matches(*result)) {
|
||||
result = none();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user