mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
parent
335f397277
commit
704517e237
4 changed files with 23 additions and 2 deletions
|
@ -646,12 +646,11 @@ static int set_var_array(const wchar_t *cmd, set_cmd_opts_t &opts, const wchar_t
|
||||||
UNUSED(streams);
|
UNUSED(streams);
|
||||||
|
|
||||||
if (opts.prepend || opts.append) {
|
if (opts.prepend || opts.append) {
|
||||||
int scope = compute_scope(opts);
|
|
||||||
if (opts.prepend) {
|
if (opts.prepend) {
|
||||||
for (int i = 0; i < argc; i++) new_values.push_back(argv[i]);
|
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;
|
wcstring_list_t var_array;
|
||||||
if (!var_str.missing()) var_str.to_list(var_array);
|
if (!var_str.missing()) var_str.to_list(var_array);
|
||||||
new_values.insert(new_values.end(), var_array.begin(), var_array.end());
|
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
|
# 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 -g var5 abc def
|
||||||
set -a -p var5 0 x 0
|
set -a -p var5 0 x 0
|
||||||
set --show var5
|
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[8]: length=1 value=|0|
|
||||||
$var5: not set in universal scope
|
$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 a new issue