mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 18:21:16 -03:00
Do not import vars that are equivalent to a universal exported var
Universal exported variables (created by `set -xU`) used to show up both as universal and global variable in child instances of fish. As a result, when changing an exported universal variable, the new value would only be visible after a new login (or deleting the variable from global scope in each fish instance). Additionally, something like `set -xU EDITOR vim -g` would be imported into the global scope as a single word resulting in failures to execute $EDITOR in fish. We cannot simply give precedence to universal variables, because another process might have exported the same variable. Instead, we only skip importing a variable when it is equivalent to an exported universal variable with the same name. We compare their values after joining with spaces, hence skipping those imports does not change the environment fish passes to its children. Only the representation in fish is changed from `"vim -g"` to `vim -g`. Closes #5258. This eliminates the issue #5348 for universal variables.
This commit is contained in:
@@ -462,4 +462,16 @@ begin
|
||||
# CHECK: inner
|
||||
end
|
||||
|
||||
# Skip importing universal variables (#5258)
|
||||
while set -q EDITOR; set -e EDITOR; end
|
||||
set -Ux EDITOR emacs -nw
|
||||
# CHECK: $EDITOR: not set in global scope
|
||||
# CHECK: $EDITOR: set in universal scope, exported, with 2 elements
|
||||
$FISH -c 'set -S EDITOR' | string match -r -e 'global|universal'
|
||||
|
||||
# When the variable has been changed outside of fish we accept it.
|
||||
# CHECK: $EDITOR: set in global scope, exported, with 1 elements
|
||||
# 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'
|
||||
|
||||
true
|
||||
|
||||
Reference in New Issue
Block a user