mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
parent
335f397277
commit
704517e237
|
@ -646,12 +646,11 @@ static int set_var_array(const wchar_t *cmd, set_cmd_opts_t &opts, const wchar_t
|
|||
UNUSED(streams);
|
||||
|
||||
if (opts.prepend || opts.append) {
|
||||
int scope = compute_scope(opts);
|
||||
if (opts.prepend) {
|
||||
for (int i = 0; i < argc; i++) new_values.push_back(argv[i]);
|
||||
}
|
||||
|
||||
env_var_t var_str = env_get(varname, scope);
|
||||
env_var_t var_str = env_get(varname, ENV_DEFAULT);
|
||||
wcstring_list_t var_array;
|
||||
if (!var_str.missing()) var_str.to_list(var_array);
|
||||
new_values.insert(new_values.end(), var_array.begin(), var_array.end());
|
||||
|
|
|
@ -14,3 +14,6 @@ $argle bargle: invalid var name
|
|||
|
||||
####################
|
||||
# Appending and prepending at same time works
|
||||
|
||||
####################
|
||||
# Setting local scope when no local scope of the var uses the closest scope
|
||||
|
|
|
@ -47,3 +47,10 @@ logmsg Appending and prepending at same time works
|
|||
set -g var5 abc def
|
||||
set -a -p var5 0 x 0
|
||||
set --show var5
|
||||
|
||||
logmsg Setting local scope when no local scope of the var uses the closest scope
|
||||
set -g var6 ghi jkl
|
||||
begin
|
||||
set -l -a var6 mno
|
||||
set --show var6
|
||||
end
|
||||
|
|
|
@ -88,3 +88,15 @@ $var5[7]: length=1 value=|x|
|
|||
$var5[8]: length=1 value=|0|
|
||||
$var5: not set in universal scope
|
||||
|
||||
|
||||
####################
|
||||
# Setting local scope when no local scope of the var uses the closest scope
|
||||
$var6: set in local scope, unexported, with 3 elements
|
||||
$var6[1]: length=3 value=|ghi|
|
||||
$var6[2]: length=3 value=|jkl|
|
||||
$var6[3]: length=3 value=|mno|
|
||||
$var6: set in global scope, unexported, with 2 elements
|
||||
$var6[1]: length=3 value=|ghi|
|
||||
$var6[2]: length=3 value=|jkl|
|
||||
$var6: not set in universal scope
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user