mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
improve set -U
warning
Doing `set -U var` when a global named `var` exists can result in confusing behavior. Try to limit the confusion by improving the warning we write. Also, only write the warning if interactive. Fixes #4267
This commit is contained in:
parent
0988f53c70
commit
4f5bd08b20
1 changed files with 2 additions and 2 deletions
|
@ -694,9 +694,9 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
// Check if we are setting variables above the effective scope. See
|
||||
// https://github.com/fish-shell/fish-shell/issues/806
|
||||
env_var_t global_dest = env_get_string(dest, ENV_GLOBAL);
|
||||
if (universal && !global_dest.missing()) {
|
||||
if (universal && !global_dest.missing() && shell_is_interactive()) {
|
||||
streams.err.append_format(
|
||||
_(L"%ls: Warning: universal scope selected, but a global variable '%ls' exists.\n"),
|
||||
_(L"%ls: Universal var '%ls' created but shadowed by global var of the same name.\n"),
|
||||
L"set", dest);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue