hush: fix ${##}, ${#?}, ${#!} handling
function old new delta parse_dollar 786 820 +34 expand_one_var 1579 1592 +13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 47/0) Total: 47 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
31
shell/hush_test/hush-vars/param_expand_len1.tests
Executable file
31
shell/hush_test/hush-vars/param_expand_len1.tests
Executable file
@@ -0,0 +1,31 @@
|
||||
# ${#c} for any single char c means "length of $c", including all special vars
|
||||
|
||||
false
|
||||
echo One:${#?}
|
||||
(exit 10)
|
||||
echo Two:${#?}
|
||||
(exit 100)
|
||||
echo Three:${#?}
|
||||
|
||||
echo
|
||||
echo One:${##}
|
||||
set -- 1 2 3 4 5 6 7 8 9 0
|
||||
echo Two:${##}
|
||||
set -- 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 \
|
||||
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 \
|
||||
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 \
|
||||
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
|
||||
echo Three:${##}
|
||||
|
||||
echo
|
||||
v=$$
|
||||
test "${#v}" = "${#$}"
|
||||
echo 'Ok ${#$}:' $?
|
||||
|
||||
echo
|
||||
sleep 0 &
|
||||
v=$!
|
||||
test "${#v}" = "${#!}"
|
||||
echo 'Ok ${#!}:' $?
|
||||
|
||||
# TODO: ${#-} ${#_}
|
Reference in New Issue
Block a user