mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-24 14:01:15 -03:00
Allow overwriting argv with function -a and -V
Previously, if you called a function parameter 'argv', within the body of the function, argv would be set to *all* the arguments to the function, and not the one indicated by the parameter name. The same behaviour happened if you inherited a variable named 'argv'. Both behaviours were quite surprising, so this commit makes things more obvious, although they could alternatively simply be made errors. Part of #11780
This commit is contained in:
committed by
Johannes Altmanninger
parent
7a07c08860
commit
93c4d63295
@@ -192,4 +192,26 @@ end
|
||||
# CHECKERR: function ()
|
||||
# CHECKERR: ^
|
||||
|
||||
# Tests the --argument-names and --inherit-variable can overwrite argv
|
||||
function t --argument-names a argv c
|
||||
echo $argv
|
||||
end
|
||||
t 1 2 3
|
||||
#CHECK: 2
|
||||
|
||||
function t -a argv
|
||||
echo $argv
|
||||
end
|
||||
t 1 2 3
|
||||
#CHECK: 1
|
||||
|
||||
function outer
|
||||
function inner -v argv -V argv
|
||||
echo $argv
|
||||
end
|
||||
set -gx argv 4 5 6
|
||||
end
|
||||
outer 1 2 3
|
||||
#CHECK: 1 2 3
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user