mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
320cb6857f
Specifically, an invalid flag keeps the function from being defined but does not emit an error message. Fixes #2827
46 lines
1.3 KiB
Fish
46 lines
1.3 KiB
Fish
# vim: set filetype=fish:
|
|
#
|
|
# Test the `function` builtin
|
|
|
|
# utility function
|
|
function show_ary -a name --no-scope-shadowing
|
|
set -l count (count $$name)
|
|
echo "\$$name: ($count)"
|
|
if test $count -gt 0
|
|
for i in (seq $count)
|
|
echo "$i: '$$name[1][$i]'"
|
|
end
|
|
end
|
|
end
|
|
|
|
# Test the -V flag
|
|
set -g foo 'global foo'
|
|
set -l foo 'local foo'
|
|
set bar one 'two 2' \t '' 3
|
|
set baz
|
|
function frob -V foo -V bar -V baz
|
|
show_ary foo
|
|
show_ary bar
|
|
show_ary baz
|
|
end
|
|
echo "Testing -V"
|
|
frob
|
|
echo "Testing -V with changed variables"
|
|
set foo 'bad foo'
|
|
set bar 'bad bar'
|
|
set baz 'bad baz'
|
|
frob
|
|
|
|
# This sequence of tests originally verified that functions `name2` and
|
|
# `name4` were created. See issue #2068. That behavior is not what we want.
|
|
# The function name must always be the first argument of the `function`
|
|
# command. See issue #2827.
|
|
function name1 -a arg1 arg2 ; end
|
|
function -a arg1 arg2 name2 ; end
|
|
function name3 --argument-names arg1 arg2 ; end
|
|
function --argument-names arg1 arg2 name4 ; end
|
|
function name5 abc --argument-names def ; end
|
|
functions -q name1; and echo "Function name1 found"
|
|
functions -q name2; or echo "Function name2 not found as expected"
|
|
functions -q name3; and echo "Function name3 found"
|
|
functions -q name4; or echo "Function name4 not found as expected"
|