Update exports when an exported universal variable changes

Fixes #6612
This commit is contained in:
Johannes Altmanninger 2020-02-16 18:51:19 +01:00
parent 7e6baab153
commit 7517128b68
2 changed files with 11 additions and 3 deletions

View File

@ -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()));
}
}

View File

@ -649,4 +649,11 @@ test_ifforwhile_scope
set -g status 5
#CHECKERR: set: Tried to change the read-only variable 'status'
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