If no uvars are available, fall back to global when setting

Otherwise `set -U foo bar` if uvars aren't available would simply not
set *anything*.
This commit is contained in:
Fabian Homborg
2021-04-11 11:07:44 +02:00
parent 52f56e2119
commit 980365735a
2 changed files with 6 additions and 3 deletions

View File

@@ -1170,10 +1170,12 @@ mod_result_t env_stack_impl_t::set(const wcstring &key, env_mode_flags_t mode,
mod_result_t result{ENV_OK};
if (query.has_scope) {
// The user requested a particular scope.
if (query.universal) {
//
// If we don't have uvars, fall back to using globals
if (query.universal && uvars()) {
set_universal(key, std::move(val), query);
result.uvar_modified = true;
} else if (query.global) {
} else if (query.global || (query.universal && !uvars())) {
set_in_node(globals_, key, std::move(val), flags);
result.global_modified = true;
} else if (query.local) {