diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-04-09 16:13:32 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-04-09 16:15:01 -0700 |
commit | 2d698b6e42d8dca191ac795ef5dba3bf62496eec (patch) | |
tree | ac5e0b67043c50f49160e9fe407435706cf30444 /tests | |
parent | f1250933e4a2ac09a3d0b25b3877068e12f44da5 (diff) | |
download | vyatta-bash-2d698b6e42d8dca191ac795ef5dba3bf62496eec.tar.gz vyatta-bash-2d698b6e42d8dca191ac795ef5dba3bf62496eec.zip |
Integrate bash 3.2 version
This is merge of current Debian stable (Lenny) version of Bash
with Vyatta changes.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/README | 2 | ||||
-rw-r--r-- | tests/array.right | 17 | ||||
-rw-r--r-- | tests/array.tests | 7 | ||||
-rw-r--r-- | tests/braces.right | 2 | ||||
-rw-r--r-- | tests/braces.tests | 5 | ||||
-rw-r--r-- | tests/cprint.right | 20 | ||||
-rw-r--r-- | tests/extglob.right | 9 | ||||
-rw-r--r-- | tests/extglob.tests | 4 | ||||
-rw-r--r-- | tests/func.right | 3 | ||||
-rw-r--r-- | tests/func.tests | 10 | ||||
-rw-r--r-- | tests/heredoc.right | 4 | ||||
-rw-r--r-- | tests/new-exp.right | 17 | ||||
-rw-r--r-- | tests/new-exp.tests | 16 | ||||
-rw-r--r-- | tests/nquote.right | 5 | ||||
-rw-r--r-- | tests/nquote.tests | 14 | ||||
-rw-r--r-- | tests/printf.tests | 9 | ||||
-rw-r--r-- | tests/quote.right | 26 | ||||
-rw-r--r-- | tests/quote.tests | 48 | ||||
-rw-r--r-- | tests/redir.right | 2 | ||||
-rw-r--r-- | tests/tilde.right | 1 | ||||
-rw-r--r-- | tests/tilde.tests | 3 |
21 files changed, 194 insertions, 30 deletions
diff --git a/tests/README b/tests/README index a1a081b..b023ef6 100644 --- a/tests/README +++ b/tests/README @@ -1 +1,3 @@ Type `sh run-all'. + +Read COPYRIGHT for copyright information. diff --git a/tests/array.right b/tests/array.right index 488b4e4..53a7a00 100644 --- a/tests/array.right +++ b/tests/array.right @@ -137,6 +137,14 @@ value = new1 new2 new3 7 8 9 +8 11 +8 11 +6 +6 +nordholz +8 +8 +8 a b c d e f g for case if then else @@ -144,10 +152,10 @@ for case if then else 12 14 16 18 20 4414758999202 aaa bbb -./array.tests: line 282: syntax error near unexpected token `<>' -./array.tests: line 282: `metas=( <> < > ! )' -./array.tests: line 283: syntax error near unexpected token `<>' -./array.tests: line 283: `metas=( [1]=<> [2]=< [3]=> [4]=! )' +./array.tests: line 285: syntax error near unexpected token `<>' +./array.tests: line 285: `metas=( <> < > ! )' +./array.tests: line 286: syntax error near unexpected token `<>' +./array.tests: line 286: `metas=( [1]=<> [2]=< [3]=> [4]=! )' abc 3 case 4 abc case if then else 5 @@ -197,3 +205,4 @@ t [3]=abcde r s t u v e 9 +2 diff --git a/tests/array.tests b/tests/array.tests index 4a735d8..ce46179 100644 --- a/tests/array.tests +++ b/tests/array.tests @@ -242,6 +242,9 @@ ${THIS_SH} ./array2.sub # some old bugs and ksh93 compatibility tests ${THIS_SH} ./array3.sub +# some compound assingment parsing problems that showed up in bash-3.1-release +${THIS_SH} ./array4.sub + set +u cd /tmp @@ -396,3 +399,7 @@ unset x[2] x[9]='9' echo ${x[*]: -1} + +TOOLKIT=(1 2 3 4 5 6 7 8 9 10) +ARRAY="1" +echo ${TOOLKIT["$ARRAY"]} diff --git a/tests/braces.right b/tests/braces.right index 3d7ef8e..f00d39a 100644 --- a/tests/braces.right +++ b/tests/braces.right @@ -41,3 +41,5 @@ f 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 +a-{bd}-c a-{be}-c +a-{bdef-g-c a-{bdef-i-c diff --git a/tests/braces.tests b/tests/braces.tests index 3f57829..5a57f28 100644 --- a/tests/braces.tests +++ b/tests/braces.tests @@ -68,3 +68,8 @@ echo 0{1..9} {10..20} # do negative numbers work? echo {-1..-10} echo {-20..0} + +# weirdly-formed brace expansions -- fixed in post-bash-3.1 +echo a-{b{d,e}}-c + +echo a-{bdef-{g,i}-c diff --git a/tests/cprint.right b/tests/cprint.right index 5dd629d..2000072 100644 --- a/tests/cprint.right +++ b/tests/cprint.right @@ -1,14 +1,14 @@ tf is a function tf () { - echo this is ${0##*/} >/dev/null; - echo a | cat - >/dev/null; + echo this is ${0##*/} > /dev/null; + echo a | cat - > /dev/null; test -f ${0##*/} && echo ${0##*/} is a regular file; test -d ${0##*/} || echo ${0##*/} is not a directory; echo a; echo b; echo c; - echo background >/dev/null & ( exit 1 ); + echo background > /dev/null & ( exit 1 ); echo $?; { echo a @@ -18,20 +18,20 @@ tf () test -r /dev/fd/$i; i=$(( i + 1 )); done; - [[ -r /dev/fd/0 && -w /dev/fd/1 ]] || echo oops >/dev/null; + [[ -r /dev/fd/0 && -w /dev/fd/1 ]] || echo oops > /dev/null; for name in $( echo 1 2 3 ); do test -r /dev/fd/$name; done; if [[ -r /dev/fd/0 && -w /dev/fd/1 ]]; then - echo ok >/dev/null; + echo ok > /dev/null; else if (( 7 > 40 )); then echo oops; else echo done; fi; - fi >/dev/null; + fi > /dev/null; case $PATH in *$PWD*) echo \$PWD in \$PATH @@ -39,13 +39,13 @@ tf () *) echo \$PWD not in \$PATH ;; - esac >/dev/null; + esac > /dev/null; while false; do echo z; - done >/dev/null; + done > /dev/null; until true; do echo z; - done >/dev/null; + done > /dev/null; echo \&\|'()' \{ echo abcde \; \}; eval fu\%nc'()' \{ echo abcde \; \}; type fu\%nc @@ -54,7 +54,7 @@ tf2 is a function tf2 () { ( { - time -p echo a | cat - >/dev/null + time -p echo a | cat - > /dev/null } ) 2>&1 } cprint.tests is a regular file diff --git a/tests/extglob.right b/tests/extglob.right index f063b26..301e97b 100644 --- a/tests/extglob.right +++ b/tests/extglob.right @@ -78,3 +78,12 @@ a b a,b a-b a.b a:b a;b a_b a b a,b a-b a.b a:b a;b a_b a b a,b a-b a.b a:b a;b a_b argv[1] = <ef> +a.c +a.c +a.c +a.c +a.c +a.c +ok 1 +ok 2 +ok 3 diff --git a/tests/extglob.tests b/tests/extglob.tests index 2d93850..51e33ee 100644 --- a/tests/extglob.tests +++ b/tests/extglob.tests @@ -193,7 +193,7 @@ esac MYDIR=$PWD # save where we are -TESTDIR=/tmp/eglob-test +TESTDIR=/tmp/eglob-test-$$ mkdir $TESTDIR builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; } rm -rf * @@ -360,4 +360,6 @@ recho "${x#*(a|b)cd}" # in the right place builtin cd $MYDIR +${THIS_SH} ./extglob1.sub + exit 0 diff --git a/tests/func.right b/tests/func.right index e51d92b..e97a486 100644 --- a/tests/func.right +++ b/tests/func.right @@ -27,7 +27,7 @@ f1 () return $status } before: try to assign to FUNCNAME -outside: FUNCNAME = +outside: FUNCNAME = main before: FUNCNAME = func FUNCNAME = func2 after: FUNCNAME = func @@ -148,3 +148,4 @@ expect 2 40 2 40 expect 5 20 5 20 +5 diff --git a/tests/func.tests b/tests/func.tests index 063f4e0..23dff44 100644 --- a/tests/func.tests +++ b/tests/func.tests @@ -132,7 +132,7 @@ func() } echo before: try to assign to FUNCNAME -FUCNAME=7 +FUNCNAME=7 echo outside: FUNCNAME = $FUNCNAME func @@ -165,4 +165,12 @@ myfunction() { myfunction myfunction | cat +segv() +{ + echo foo | return 5 +} + +segv +echo $? + exit 0 diff --git a/tests/heredoc.right b/tests/heredoc.right index d71781e..c3f6a7f 100644 --- a/tests/heredoc.right +++ b/tests/heredoc.right @@ -20,7 +20,7 @@ jkl mno fff is a function fff () { - ed /tmp/foo >/dev/null <<ENDOFINPUT + ed /tmp/foo > /dev/null <<ENDOFINPUT /^name/d w q @@ -31,7 +31,7 @@ ENDOFINPUT fff is a function fff () { - ed /tmp/foo >/dev/null <<ENDOFINPUT + ed /tmp/foo > /dev/null <<ENDOFINPUT /^name/d w q diff --git a/tests/new-exp.right b/tests/new-exp.right index 8866835..f2dfbc1 100644 --- a/tests/new-exp.right +++ b/tests/new-exp.right @@ -430,7 +430,7 @@ Case05---3---A:B:C--- Case06---1---A B C::--- Case07---3---A:B:C--- Case08---3---A:B:C--- -./new-exp.tests: line 506: ${$(($#-1))}: bad substitution +./new-exp.tests: line 506: /${$(($#-1))}: bad substitution argv[1] = <a> argv[2] = <b> argv[3] = <c> @@ -502,4 +502,17 @@ h --blah lah lah -./new-exp.tests: line 558: ABXD: parameter unset +argv[1] = <> +argv[1] = <+> +argv[1] = <+^?> +argv[1] = <+> +argv[1] = <^?2> +argv[1] = <^?2> +argv[1] = <^?> +argv[1] = <^?> +argv[1] = <> +argv[1] = <> +argv[1] = <> +argv[1] = <> +argv[1] = <12> +./new-exp.tests: line 560: ABXD: parameter unset diff --git a/tests/new-exp.tests b/tests/new-exp.tests index e0c2702..78a0e7f 100644 --- a/tests/new-exp.tests +++ b/tests/new-exp.tests @@ -212,9 +212,9 @@ recho ${av[1]/??/za} expect '<zaza>' recho ${av[1]//??/za} expect '<zagh>' -recho ${av[1]//#??/za} +recho ${av[1]/#??/za} expect '<efza>' -recho ${av[1]//%??/za} +recho ${av[1]/%??/za} expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>' recho ${av[@]/*/yyy} @@ -238,17 +238,17 @@ recho ${@/%??/xx} expect '<zaza>' recho ${3//??/za} expect '<efza>' -recho ${3//%??/za} +recho ${3/%??/za} expect '<zaza> <zaza> <zaza> <zaza> <zaza> <zaza>' recho ${@//??/za} expect '<zacd> <zagh> <zakl> <zaop> <zast> <zawx>' -recho ${@//#??/za} +recho ${@/#??/za} expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>' recho ${@//*/yyy} expect '<yyy> <efgh> <ijkl> <mnop> <qrst> <uvwx>' recho ${@//a*/yyy} expect '<abcd> <efgh> <ijkl> <mnop> <qrst> <uvwyyy>' -recho ${@//%x*/yyy} +recho ${@/%x*/yyy} expect a newline echo $abmcde @@ -548,11 +548,13 @@ var=blah # these had better agree echo ${var[@]:3} echo ${var:3} -echo ${var[@]//#/--} -echo ${var//#/--} +echo ${var[@]/#/--} +echo ${var/#/--} echo ${var[@]##?} echo ${var##?} +${THIS_SH} ./new-exp6.sub + # this must be last! expect $0: 'ABXD: parameter unset' recho ${ABXD:?"parameter unset"} diff --git a/tests/nquote.right b/tests/nquote.right index 904467b..6d936d5 100644 --- a/tests/nquote.right +++ b/tests/nquote.right @@ -30,3 +30,8 @@ argv[1] = <hello, $"world"> argv[1] = <hello, \$"world"> argv[1] = <hello, $"world"> argv[1] = <hello, $world> +1 +1 +;foo +argv[1] = <^I> +argv[1] = <'A^IB'> diff --git a/tests/nquote.tests b/tests/nquote.tests index b25fbe3..62d90b9 100644 --- a/tests/nquote.tests +++ b/tests/nquote.tests @@ -100,3 +100,17 @@ recho $'hello, \$"world"' recho $'hello, $\"world"' recho "hello, $"world"" + +# ansi quoting inside double-quoted command subst - bash-3.1 bug +echo $(set -- $'a b'; echo $#) +echo "$(set -- $'a b'; echo $#)" + +echo "$(echo $';foo')" + +args () +{ + for a in "$@";do echo "'$a'";done +} +unset mytab +recho "${mytab:-$'\t'}" +recho "$( args $'A\tB' )" diff --git a/tests/printf.tests b/tests/printf.tests index 9cd7302..60928d6 100644 --- a/tests/printf.tests +++ b/tests/printf.tests @@ -67,7 +67,7 @@ printf -- "--%b--\n" '\t\0101' printf -- "--%b--\n" '\t\101' # these should all display `A7' -echo -e "\1017" +echo -e "\01017" echo -e "\x417" printf "%b\n" '\01017' @@ -246,3 +246,10 @@ printf '\x07e\n' # additional backslash escapes printf '\"\?\n' + +# failures with decimal precisions until after bash-3.1 +printf '%0.5d\n' 1 + +printf '%05d\n' 1 +printf '%5d\n' 1 +printf '%0d\n' 1 diff --git a/tests/quote.right b/tests/quote.right index 8d71f5d..424d1a0 100644 --- a/tests/quote.right +++ b/tests/quote.right @@ -40,3 +40,29 @@ foo bar foo\ bar +argv[1] = <foo \\^Jbar> +argv[1] = <foo \^Jbar> +argv[1] = <sed> argv[2] = <-e> argv[3] = <s/[^I:]/\^J/g> +argv[1] = <sed> argv[2] = <-e> argv[3] = <s/[^I:]//g> +argv[1] = <foo\^Jbar> +argv[1] = <foobar> +argv[1] = <foo\^Jbar> +b +a +b +c +argv[1] = <a\> +argv[2] = <b> +argv[1] = <$> +argv[2] = <bab> +argv[1] = <$foo> +argv[2] = <bab> +argv[1] = <$foo> +argv[2] = <bab> +argv[1] = <`> +argv[2] = <ab> +argv[1] = <\> +argv[2] = <ab> +${ +argv[1] = <(")> +argv[1] = <(")> diff --git a/tests/quote.tests b/tests/quote.tests index 152ea5a..46edea7 100644 --- a/tests/quote.tests +++ b/tests/quote.tests @@ -61,3 +61,51 @@ echo "$(echo 'foo bar')" echo "$(echo 'foo\ bar')" + +# old-style command substitution parsing compatibility tests -- post bash-3.1 +recho 'foo \\ +bar' + +recho 'foo \ +bar' + +echo `recho sed -e 's/[ :]/\\ +/g'` + +echo `recho sed -e 's/[ :]/\ +/g'` + +echo `recho 'foo\\ +bar'` + +echo `recho 'foo\ +bar'` + +echo $(recho 'foo\ +bar') + +a=`echo 'a b c' | sed 's/ /\\ +/g' | grep 'b'` +echo $a +a=`echo 'a b c' | sed 's/ /\\ +/g'` +echo "$a" + +recho `echo 'a\' b` + +recho `echo '\$' bab` +recho `echo '\$foo' bab` +recho `echo '$foo' bab` + +recho `echo '\`' ab` + +recho `echo '\\' ab` + +echo `echo '${'` + +recho `echo "(\\")"` +# produces no output +: `: "\\""` +# ultimate workaround +recho `echo "(\")"` + diff --git a/tests/redir.right b/tests/redir.right index 68bea52..e56b980 100644 --- a/tests/redir.right +++ b/tests/redir.right @@ -78,7 +78,7 @@ read line echo $line f () { - exec 5<$0; + exec 5< $0; exec 0<&5-; while read line; do echo "$line"; diff --git a/tests/tilde.right b/tests/tilde.right index b22dabf..fe58ae3 100644 --- a/tests/tilde.right +++ b/tests/tilde.right @@ -22,3 +22,4 @@ abcd:~chet ok 1 ok 2 ok 3 +~root diff --git a/tests/tilde.tests b/tests/tilde.tests index f5f5309..8b2bdb8 100644 --- a/tests/tilde.tests +++ b/tests/tilde.tests @@ -64,3 +64,6 @@ case $unset in "") echo ok 3 ;; *) echo bad 3 ;; esac + +USER=root # should exist just about everywhere +echo ~$USER |