From 971a837031c004bb99a6ab56cb2d3bb260e77825 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 16 Feb 2020 18:51:19 +0100 Subject: [PATCH] Update exports when an exported universal variable changes Fixes #6612 (cherry picked from commit 7517128b68a99dd24060caad649a21fea48e1c9e) --- src/env_universal_common.cpp | 7 ++++--- tests/checks/set.fish | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index 8c5885b96..c977369a5 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -346,11 +346,12 @@ void env_universal_t::generate_callbacks_and_update_exports(const var_table_t &n bool old_exports = (existing != this->vars.end() && existing->second.exports()); bool export_changed = (old_exports != new_entry.exports()); - if (export_changed) { + bool value_changed = existing != this->vars.end() && existing->second != new_entry; + if (export_changed || value_changed) { export_generation += 1; } - if (existing == this->vars.end() || export_changed || existing->second != new_entry) { - // Value has changed. + if (existing == this->vars.end() || export_changed || value_changed) { + // Value is set for the first time, or has changed. callbacks.push_back(callback_data_t(key, new_entry.as_string())); } } diff --git a/tests/checks/set.fish b/tests/checks/set.fish index 070fda35d..b6f36841b 100644 --- a/tests/checks/set.fish +++ b/tests/checks/set.fish @@ -480,4 +480,11 @@ $FISH -c 'set -S EDITOR' | string match -r -e 'global|universal' # CHECK: $EDITOR: set in universal scope, exported, with 2 elements sh -c "EDITOR='vim -g' $FISH -c "'\'set -S EDITOR\'' | string match -r -e 'global|universal' +while set -e __fish_test_universal_exported_var +end +set -xU __fish_test_universal_exported_var 1 +$FISH -c 'set __fish_test_universal_exported_var 2' +env | string match -e __fish_test_universal_exported_var +#CHECK: __fish_test_universal_exported_var=2 + true