diff options
Diffstat (limited to 'release/src/router/busybox/shell/hush_test/hush-vars')
42 files changed, 590 insertions, 0 deletions
diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/empty.right b/release/src/router/busybox/shell/hush_test/hush-vars/empty.right new file mode 100644 index 00000000..2cb3c70f --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/empty.right @@ -0,0 +1,3 @@ +a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F +a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F +a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/empty.tests b/release/src/router/busybox/shell/hush_test/hush-vars/empty.tests new file mode 100755 index 00000000..a9c247e3 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/empty.tests @@ -0,0 +1,5 @@ +e= + +echo a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F +echo a $e b $e c $e d $e e $e f $e 1 $e 2 $e 3 $e 4 $e 5 $e 6 $e 7 $e 8 $e 9 $e 0 $e A $e B $e C $e D $e E $e F +echo $e a $e b $e c $e d $e e $e f $e 1 $e 2 $e 3 $e 4 $e 5 $e 6 $e 7 $e 8 $e 9 $e 0 $e A $e B $e C $e D $e E $e F diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/glob_and_vars.right b/release/src/router/busybox/shell/hush_test/hush-vars/glob_and_vars.right new file mode 100644 index 00000000..3ac7ec5f --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/glob_and_vars.right @@ -0,0 +1 @@ +./glob_and_vars.right ./glob_and_vars.tests diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/glob_and_vars.tests b/release/src/router/busybox/shell/hush_test/hush-vars/glob_and_vars.tests new file mode 100755 index 00000000..482cf9d8 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/glob_and_vars.tests @@ -0,0 +1,2 @@ +v=. +echo $v/glob_and_vars.[tr]* diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_alt.right b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_alt.right new file mode 100644 index 00000000..4d2197a5 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_alt.right @@ -0,0 +1,8 @@ +hush: syntax error: unterminated ${name} +hush: syntax error: unterminated ${name} +_0 _0 +_ _ _ _ _ +_aaaa _ _ _word _word +_ _ _ _ _ +_ _ _ _word _ +_fff _ _ _word _word diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_alt.tests b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_alt.tests new file mode 100755 index 00000000..dcdca86d --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_alt.tests @@ -0,0 +1,22 @@ +# first try some invalid patterns (do in subshell due to parsing error) +"$THIS_SH" -c 'echo ${+} ; echo moo' +"$THIS_SH" -c 'echo ${:+} ; echo moo' + +# now some funky ones +echo _${#+} _${#:+} + +# now some valid ones +set -- +echo _$1 _${1+} _${1:+} _${1+word} _${1:+word} + +set -- aaaa +echo _$1 _${1+} _${1:+} _${1+word} _${1:+word} + +unset f +echo _$f _${f+} _${f:+} _${f+word} _${f:+word} + +f= +echo _$f _${f+} _${f:+} _${f+word} _${f:+word} + +f=fff +echo _$f _${f+} _${f:+} _${f+word} _${f:+word} diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_assign.right b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_assign.right new file mode 100644 index 00000000..d5b25807 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_assign.right @@ -0,0 +1,27 @@ +hush: syntax error: unterminated ${name} +hush: syntax error: unterminated ${name} +0 +0 +hush: $1: cannot assign in this way +hush: $1: cannot assign in this way +hush: $1: cannot assign in this way +hush: $1: cannot assign in this way +_aa +_aa +_aa +_aa +_ +_ +_ +_word +_word +_ +_ +_ +_ +_word +_fff +_fff +_fff +_fff +_fff diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_assign.tests b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_assign.tests new file mode 100755 index 00000000..149cb20d --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_assign.tests @@ -0,0 +1,38 @@ +# first try some invalid patterns (do in subshell due to parsing error) +"$THIS_SH" -c 'echo ${=}' +"$THIS_SH" -c 'echo ${:=}' + +# now some funky ones +"$THIS_SH" -c 'echo ${#=}' +"$THIS_SH" -c 'echo ${#:=}' + +# should error out +"$THIS_SH" -c 'set --; echo _${1=}' +"$THIS_SH" -c 'set --; echo _${1:=}' +"$THIS_SH" -c 'set --; echo _${1=word}' +"$THIS_SH" -c 'set --; echo _${1:=word}' + +# should not error +"$THIS_SH" -c 'set aa; echo _${1=}' +"$THIS_SH" -c 'set aa; echo _${1:=}' +"$THIS_SH" -c 'set aa; echo _${1=word}' +"$THIS_SH" -c 'set aa; echo _${1:=word}' + +# should work fine +unset f; echo _$f +unset f; echo _${f=} +unset f; echo _${f:=} +unset f; echo _${f=word} +unset f; echo _${f:=word} + +f=; echo _$f +f=; echo _${f=} +f=; echo _${f:=} +f=; echo _${f=word} +f=; echo _${f:=word} + +f=fff; echo _$f +f=fff; echo _${f=} +f=fff; echo _${f:=} +f=fff; echo _${f=word} +f=fff; echo _${f:=word} diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_default.right b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_default.right new file mode 100644 index 00000000..acc71720 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_default.right @@ -0,0 +1,8 @@ +hush: syntax error: unterminated ${name} +hush: syntax error: unterminated ${name} +_0 _0 +_ _ _ _word _word +_aaaa _aaaa _aaaa _aaaa _aaaa +_ _ _ _word _word +_ _ _ _ _word +_fff _fff _fff _fff _fff diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_default.tests b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_default.tests new file mode 100755 index 00000000..1ea05174 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_default.tests @@ -0,0 +1,22 @@ +# first try some invalid patterns (do in subshell due to parsing error) +"$THIS_SH" -c 'echo ${-}' +"$THIS_SH" -c 'echo ${:-}' + +# now some funky ones +echo _${#-} _${#:-} + +# now some valid ones +set -- +echo _$1 _${1-} _${1:-} _${1-word} _${1:-word} + +set -- aaaa +echo _$1 _${1-} _${1:-} _${1-word} _${1:-word} + +unset f +echo _$f _${f-} _${f:-} _${f-word} _${f:-word} + +f= +echo _$f _${f-} _${f:-} _${f-word} _${f:-word} + +f=fff +echo _$f _${f-} _${f:-} _${f-word} _${f:-word} diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_indicate_error.right b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_indicate_error.right new file mode 100644 index 00000000..590bb200 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_indicate_error.right @@ -0,0 +1,28 @@ +hush: syntax error: unterminated ${name} +0 +0 +_ +hush: 1: parameter null or not set +hush: 1: parameter null or not set +hush: 1: message1 +hush: 1: message1 +_aaaa +_aaaa +_aaaa +_aaaa +_aaaa +_ +hush: f: parameter null or not set +hush: f: parameter null or not set +hush: f: message3 +hush: f: message3 +_ +_ +hush: f: parameter null or not set +_ +hush: f: message4 +_fff +_fff +_fff +_fff +_fff diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_indicate_error.tests b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_indicate_error.tests new file mode 100755 index 00000000..bccba3e1 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_indicate_error.tests @@ -0,0 +1,40 @@ +# do all of these in subshells since it's supposed to error out + +# first try some invalid patterns +#"$THIS_SH" -c 'echo ${?}' -- this is valid as it's the same as $? +"$THIS_SH" -c 'echo ${:?}' + +# then some funky ones +"$THIS_SH" -c 'echo ${#?}' +"$THIS_SH" -c 'echo ${#:?}' + +# now some valid ones +"$THIS_SH" -c 'set --; echo _$1' +"$THIS_SH" -c 'set --; echo _${1?}' +"$THIS_SH" -c 'set --; echo _${1:?}' +"$THIS_SH" -c 'set --; echo _${1?message1}' +"$THIS_SH" -c 'set --; echo _${1:?message1}' + +"$THIS_SH" -c 'set -- aaaa; echo _$1' +"$THIS_SH" -c 'set -- aaaa; echo _${1?}' +"$THIS_SH" -c 'set -- aaaa; echo _${1:?}' +"$THIS_SH" -c 'set -- aaaa; echo _${1?word}' +"$THIS_SH" -c 'set -- aaaa; echo _${1:?word}' + +"$THIS_SH" -c 'unset f; echo _$f' +"$THIS_SH" -c 'unset f; echo _${f?}' +"$THIS_SH" -c 'unset f; echo _${f:?}' +"$THIS_SH" -c 'unset f; echo _${f?message3}' +"$THIS_SH" -c 'unset f; echo _${f:?message3}' + +"$THIS_SH" -c 'f=; echo _$f' +"$THIS_SH" -c 'f=; echo _${f?}' +"$THIS_SH" -c 'f=; echo _${f:?}' +"$THIS_SH" -c 'f=; echo _${f?word}' +"$THIS_SH" -c 'f=; echo _${f:?message4}' + +"$THIS_SH" -c 'f=fff; echo _$f' +"$THIS_SH" -c 'f=fff; echo _${f?}' +"$THIS_SH" -c 'f=fff; echo _${f:?}' +"$THIS_SH" -c 'f=fff; echo _${f?word}' +"$THIS_SH" -c 'f=fff; echo _${f:?word}' diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_len.right b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_len.right new file mode 100644 index 00000000..2d633a14 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_len.right @@ -0,0 +1,4 @@ +0 0 +4 4 +4 3 2 1 0 0 +0 3 0 diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_len.tests b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_len.tests new file mode 100755 index 00000000..90f47d2f --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_expand_len.tests @@ -0,0 +1,12 @@ +# make sure len parsing doesnt break arg count +set -- +echo $# ${#} +set -- aaaa bbb cc d +echo $# ${#} + +echo ${#1} ${#2} ${#3} ${#4} ${#5} ${#6} + +unset e +f=abc +g= +echo ${#e} ${#f} ${#g} diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_glob.right b/release/src/router/busybox/shell/hush_test/hush-vars/param_glob.right new file mode 100644 index 00000000..bdee8fe0 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_glob.right @@ -0,0 +1,4 @@ +param_glob.tests +param_glob.tests +param_glob.t* +param_glob.t* diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_glob.tests b/release/src/router/busybox/shell/hush_test/hush-vars/param_glob.tests new file mode 100755 index 00000000..801d58ee --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_glob.tests @@ -0,0 +1,10 @@ +if test $# = 0; then + #BUG in builtin_exec! will glob param! + #exec "$THIS_SH" "$0" 'param_glob.t*' + "$THIS_SH" "$0" 'param_glob.t*' + exit +fi +echo $* +echo $@ +echo "$*" +echo "$@" diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_subshell.right b/release/src/router/busybox/shell/hush_test/hush-vars/param_subshell.right new file mode 100644 index 00000000..f3c3767d --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_subshell.right @@ -0,0 +1,7 @@ +1=1 +2=2 +3=3 +4=4 +5=5 +6=6 +7=7 diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/param_subshell.tests b/release/src/router/busybox/shell/hush_test/hush-vars/param_subshell.tests new file mode 100755 index 00000000..27fdc5b9 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/param_subshell.tests @@ -0,0 +1,15 @@ +if test $# = 0; then + "$THIS_SH" "$0" 1 2 3 4 5 6 7 8 9 + exit +fi +echo 1=$1 +{ echo 2=$2; } +{ echo 3=$3; } & +# cant use usleep as it isnt standard in $PATH -- +# we fail when testing busybox compiled solely as "hush" +wait +( echo 4=$4 ) +( echo 5=$5 ) & +wait +true | echo 6=$6 | cat +true | { echo 7=$7; } | cat diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/star.right b/release/src/router/busybox/shell/hush_test/hush-vars/star.right new file mode 100644 index 00000000..0ecc55bc --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/star.right @@ -0,0 +1,6 @@ +.1. +.abc. +.d. +.e. +.f. +.1 abc d e f. diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/star.tests b/release/src/router/busybox/shell/hush_test/hush-vars/star.tests new file mode 100755 index 00000000..5554c409 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/star.tests @@ -0,0 +1,8 @@ +if test $# = 0; then + exec "$THIS_SH" star.tests 1 abc 'd e f' +fi +# 'd e f' should be split into 3 separate args: +for a in $*; do echo ".$a."; done + +# must produce .1 abc d e f. +for a in "$*"; do echo ".$a."; done diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/unset.right b/release/src/router/busybox/shell/hush_test/hush-vars/unset.right new file mode 100644 index 00000000..8dea7c40 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/unset.right @@ -0,0 +1,19 @@ +hush: unset: -: invalid option +1 +hush: unset: -m: invalid option +1 +0 +___ +0 f g +0 g +0 +___ +0 f g +0 +0 f g +0 +___ +hush: HUSH_VERSION: readonly variable +1 f g +hush: HUSH_VERSION: readonly variable +1 diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/unset.tests b/release/src/router/busybox/shell/hush_test/hush-vars/unset.tests new file mode 100755 index 00000000..f59ce592 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/unset.tests @@ -0,0 +1,36 @@ +# check invalid options are rejected +unset - +echo $? +unset -m a b c +echo $? + +# check funky usage +unset +echo $? + +# check normal usage +echo ___ +f=f g=g +echo $? $f $g +unset f +echo $? $f $g +unset g +echo $? $f $g + +echo ___ +f=f g=g +echo $? $f $g +unset f g +echo $? $f $g +f=f g=g +echo $? $f $g +unset -v f g +echo $? $f $g + +# check read only vars +echo ___ +f=f g=g +unset HUSH_VERSION +echo $? $f $g +unset f HUSH_VERSION g +echo $? $f $g diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var1.right b/release/src/router/busybox/shell/hush_test/hush-vars/var1.right new file mode 100644 index 00000000..194e7dbe --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var1.right @@ -0,0 +1,4 @@ +http://busybox.net +http://busybox.net_abc +1 1 +1 1 diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var1.tests b/release/src/router/busybox/shell/hush_test/hush-vars/var1.tests new file mode 100755 index 00000000..48a6782b --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var1.tests @@ -0,0 +1,9 @@ +URL=http://busybox.net + +echo $URL +echo ${URL}_abc + +true +false; echo $? ${?} +true +{ false; echo $? ${?}; } diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var2.right b/release/src/router/busybox/shell/hush_test/hush-vars/var2.right new file mode 100644 index 00000000..40bf4bff --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var2.right @@ -0,0 +1,2 @@ +http://busybox.net +http://busybox.net_abc diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var2.tests b/release/src/router/busybox/shell/hush_test/hush-vars/var2.tests new file mode 100755 index 00000000..1292410f --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var2.tests @@ -0,0 +1,4 @@ +_1=http://busybox.net + +echo $_1 +echo ${_1}_abc diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var3.right b/release/src/router/busybox/shell/hush_test/hush-vars/var3.right new file mode 100644 index 00000000..5e28d2fa --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var3.right @@ -0,0 +1,2 @@ +hush: syntax error: unterminated ${name} +hush: syntax error: unterminated ${name} diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var3.tests b/release/src/router/busybox/shell/hush_test/hush-vars/var3.tests new file mode 100755 index 00000000..aea36d62 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var3.tests @@ -0,0 +1,4 @@ +# reject invalid vars +"$THIS_SH" -c 'echo ${1q}' +"$THIS_SH" -c 'echo ${&}' +#"$THIS_SH" -c 'echo ${$}' -- this is valid as it's the same as $$ diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_assign.right b/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_assign.right new file mode 100644 index 00000000..352210d7 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_assign.right @@ -0,0 +1,5 @@ +. . +.abc d e. +.abc d e. +.abc d e. +.abc d e. diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_assign.tests b/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_assign.tests new file mode 100755 index 00000000..18cdc74c --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_assign.tests @@ -0,0 +1,15 @@ +if test $# = 0; then + exec "$THIS_SH" "$0" abc "d e" +fi + +space=' ' +echo .$space. + +a=$* +echo .$a. +a=$@ +echo .$a. +a="$*" +echo .$a. +a="$@" +echo .$a. diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_redir.right b/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_redir.right new file mode 100644 index 00000000..423299c9 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_redir.right @@ -0,0 +1,3 @@ +TEST1 +TEST2 +TEST3 diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_redir.tests b/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_redir.tests new file mode 100755 index 00000000..bda6bdd7 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_expand_in_redir.tests @@ -0,0 +1,13 @@ +if test $# = 0; then + exec "$THIS_SH" "$0" abc "d e" +fi + +echo TEST1 >"$1.out" +echo TEST2 >"$2.out" +# bash says: "$@.out": ambiguous redirect +# ash handles it as if it is '$*' - we do the same +echo TEST3 >"$@.out" + +cat abc.out "d e.out" "abc d e.out" + +rm abc.out "d e.out" "abc d e.out" diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_in_pipes.right b/release/src/router/busybox/shell/hush_test/hush-vars/var_in_pipes.right new file mode 100644 index 00000000..faf65bed --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_in_pipes.right @@ -0,0 +1,6 @@ +b=1 +b=2 +b=3 +b=4 +b=5 +b=6 diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_in_pipes.tests b/release/src/router/busybox/shell/hush_test/hush-vars/var_in_pipes.tests new file mode 100755 index 00000000..3f8cd272 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_in_pipes.tests @@ -0,0 +1,7 @@ +b=1 env | grep ^b= +true | b=2 env | grep ^b= +a=1 true | b=3 env | grep ^b= + +(b=4 env) | grep ^b= +(true | b=5 env) | grep ^b= +(a=1 true | b=6 env) | grep ^b= diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_leaks.right b/release/src/router/busybox/shell/hush_test/hush-vars/var_leaks.right new file mode 100644 index 00000000..d86bac9d --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_leaks.right @@ -0,0 +1 @@ +OK diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_leaks.tests b/release/src/router/busybox/shell/hush_test/hush-vars/var_leaks.tests new file mode 100755 index 00000000..27c8c650 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_leaks.tests @@ -0,0 +1,14 @@ +# external program +a=b /bin/true +env | grep ^a= + +# builtin +a=b true +env | grep ^a= + +# exec with redirection only +# in bash, this leaks! +a=b exec 1>&1 +env | grep ^a= + +echo OK diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_posix1.right b/release/src/router/busybox/shell/hush_test/hush-vars/var_posix1.right new file mode 100644 index 00000000..373b16ca --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_posix1.right @@ -0,0 +1,33 @@ +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +Empty: +abcdcd +abcdcd +abcdcd +cdcd +babcdcd +babcdcd +ababcdcd +Empty: +ababcd +ababcd +ababcd +abab +ababcdc +ababcdc +ababcdcd +Empty: +end diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_posix1.tests b/release/src/router/busybox/shell/hush_test/hush-vars/var_posix1.tests new file mode 100755 index 00000000..0ce531d6 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_posix1.tests @@ -0,0 +1,43 @@ +unset var + +echo Empty:${var#} +echo Empty:${var##} +echo Empty:${var#*} +echo Empty:${var##*} +echo Empty:${var%} +echo Empty:${var%%} +echo Empty:${var%*} +echo Empty:${var%%*} + +var= + +echo Empty:${var#} +echo Empty:${var##} +echo Empty:${var#*} +echo Empty:${var##*} +echo Empty:${var%} +echo Empty:${var%%} +echo Empty:${var%*} +echo Empty:${var%%*} + +var=ababcdcd + +echo ${var#ab} +echo ${var##ab} +echo ${var#a*b} +echo ${var##a*b} +echo ${var#?} +echo ${var##?} +echo ${var#*} +echo Empty:${var##*} + +echo ${var%cd} +echo ${var%%cd} +echo ${var%c*d} +echo ${var%%c*d} +echo ${var%?} +echo ${var%%?} +echo ${var%*} +echo Empty:${var%%*} + +echo end diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_preserved.right b/release/src/router/busybox/shell/hush_test/hush-vars/var_preserved.right new file mode 100644 index 00000000..2a9917c9 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_preserved.right @@ -0,0 +1,4 @@ +a=b +a=b +a=b +OK diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_preserved.tests b/release/src/router/busybox/shell/hush_test/hush-vars/var_preserved.tests new file mode 100755 index 00000000..1bddd870 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_preserved.tests @@ -0,0 +1,16 @@ +export a=b + +# external program +a=c /bin/true +env | grep ^a= + +# builtin +a=d true +env | grep ^a= + +# exec with redirection only +# in bash, this leaks! +a=e exec 1>&1 +env | grep ^a= + +echo OK diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_subst_in_for.right b/release/src/router/busybox/shell/hush_test/hush-vars/var_subst_in_for.right new file mode 100644 index 00000000..c8aca1c1 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_subst_in_for.right @@ -0,0 +1,40 @@ +Testing: in x y z +.x. +.y. +.z. +Testing: in u $empty v +.u. +.v. +Testing: in u " $empty" v +.u. +. . +.v. +Testing: in u $empty $empty$a v +.u. +.a. +.v. +Testing: in $a_b +.a. +.b. +Testing: in $* +.abc. +.d. +.e. +Testing: in $@ +.abc. +.d. +.e. +Testing: in -$*- +.-abc. +.d. +.e-. +Testing: in -$@- +.-abc. +.d. +.e-. +Testing: in $a_b -$a_b- +.a. +.b. +.-a. +.b-. +Finished diff --git a/release/src/router/busybox/shell/hush_test/hush-vars/var_subst_in_for.tests b/release/src/router/busybox/shell/hush_test/hush-vars/var_subst_in_for.tests new file mode 100755 index 00000000..433c6062 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-vars/var_subst_in_for.tests @@ -0,0 +1,40 @@ +if test $# = 0; then + exec "$THIS_SH" "$0" abc "d e" +fi + +echo 'Testing: in x y z' +for a in x y z; do echo ".$a."; done + +echo 'Testing: in u $empty v' +empty='' +for a in u $empty v; do echo ".$a."; done + +echo 'Testing: in u " $empty" v' +empty='' +for a in u " $empty" v; do echo ".$a."; done + +echo 'Testing: in u $empty $empty$a v' +a='a' +for a in u $empty $empty$a v; do echo ".$a."; done + +echo 'Testing: in $a_b' +a_b='a b' +for a in $a_b; do echo ".$a."; done + +echo 'Testing: in $*' +for a in $*; do echo ".$a."; done + +echo 'Testing: in $@' +for a in $@; do echo ".$a."; done + +echo 'Testing: in -$*-' +for a in -$*-; do echo ".$a."; done + +echo 'Testing: in -$@-' +for a in -$@-; do echo ".$a."; done + +echo 'Testing: in $a_b -$a_b-' +a_b='a b' +for a in $a_b -$a_b-; do echo ".$a."; done + +echo Finished |