From: Chet Ramey Date: Thu, 16 Oct 2025 15:44:26 +0000 (-0400) Subject: test suite updates: highlight failed test scripts; optionally save failed test output... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2a645237d3a0de3c758cd0df322973ce9446b94f;p=thirdparty%2Fbash.git test suite updates: highlight failed test scripts; optionally save failed test output; report number of successful tests; exit based on number of test failures; indent warning messages to make them stand out --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index c5242654..1fc170d0 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -11984,3 +11984,25 @@ execute_cmd.c around calls to run_debug_trap the same way we do it for run_return_trap Report from Александр Ушаков + + 10/14 + ----- +tests/run-all + - keep track of how many tests run and how many exit with status 0, + and report tests that exit with a non-zero status + Report and patch from Alexander Bantyev + - keep output of failed tests if the BASH_TSTOUT_SAVEDIR environment + variable is set to a valid directory + Report and patch from Alexander Bantyev + + 10/15 + ----- +tests/run-* + - indent the second and subsequent lines of warning messages so they + stand out a little more + +tests/*.tests + - use test_runsub to run sub-tests instead of calling ${THIS_SH} + directly, so we can print a message with the name of the sub-test + script into the output. This will help with identifying the script + that fails diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 2139f171..4f4f001f 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -10,4 +10,6 @@ export TMPDIR export BASH_TSTOUT=/tmp/xx rm -f ${BASH_TSTOUT} +export TAB=' ' + ${THIS_SH} "$@" diff --git a/tests/arith.right b/tests/arith.right index 0a7bcd72..ba0f7485 100644 --- a/tests/arith.right +++ b/tests/arith.right @@ -265,13 +265,13 @@ efg 0 0 arith9.sub -./arith9.sub: line 4: a: unbound variable -./arith9.sub: line 5: a: unbound variable +./arith9.sub: line 17: a: unbound variable +./arith9.sub: line 18: a: unbound variable 0 after 3 0 0 after 4 0 -./arith9.sub: line 14: b: expression recursion level exceeded (error token is "b") +./arith9.sub: line 27: b: expression recursion level exceeded (error token is "b") + var=42 + echo 42 42 @@ -288,7 +288,7 @@ after 4 0 + echo 1 1 + set +x -./arith9.sub: line 37: 4+: arithmetic syntax error: operand expected (error token is "+") +./arith9.sub: line 50: 4+: arithmetic syntax error: operand expected (error token is "+") x = 4+ y = arith10.sub == arraysub == diff --git a/tests/arith5.sub b/tests/arith5.sub index 7d5c7799..fdb80a7a 100644 --- a/tests/arith5.sub +++ b/tests/arith5.sub @@ -30,15 +30,15 @@ echo $(( $intmax_min2 % -1 )) echo $(( $intmax_max % -1 )) lvalue=$intmax_min1 -(( lvalue%= -1 )) +(( lvalue %= -1 )) echo $lvalue lvalue=$intmax_min2 -(( lvalue%= -1 )) +(( lvalue %= -1 )) echo $lvalue lvalue=$intmax_max -(( lvalue%= -1 )) +(( lvalue %= -1 )) echo $lvalue # and these diff --git a/tests/arith9.sub b/tests/arith9.sub index 811139ed..a3e8eb7a 100644 --- a/tests/arith9.sub +++ b/tests/arith9.sub @@ -1,3 +1,16 @@ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# # test expression evaluation with unset variables set -u diff --git a/tests/builtins.right b/tests/builtins.right index d708c188..db0f6864 100644 --- a/tests/builtins.right +++ b/tests/builtins.right @@ -85,8 +85,8 @@ enable unset enable -n test worked enable -n test enable test worked -./builtins.tests: line 126: enable: notbuiltin: not a shell builtin -./builtins.tests: line 127: enable: test: not dynamically loaded +./builtins.tests: line 128: enable: notbuiltin: not a shell builtin +./builtins.tests: line 129: enable: test: not dynamically loaded specialname -specialname FOO=BAR @@ -94,25 +94,34 @@ FOO=BAR hash: hash table empty 0 no-newline + source1.sub AVAR foo + source2.sub in source.sub2, calling return 5 + source3.sub a b c + source3.sub a b c x y z a b c + source4.sub a b c m n o p + source4.sub a b c m n o p + builtins1.sub /tmp/bash-dir-a /tmp/bash-dir-a /tmp/bash-dir-a / + source5.sub ./source5.sub: line 23: /tmp/source-notthere: No such file or directory after bad source 1 ./source5.sub: line 30: /tmp/source-notthere: No such file or directory + source6.sub one - OK 0 0 @@ -122,6 +131,7 @@ three - OK 0 four - OK 0 + source7.sub abc def ghi @@ -139,6 +149,7 @@ abc def ghi ok + source8.sub ./source8.sub: line 40: improbable-filename: No such file or directory ./source8.sub: line 41: improbable-filename: No such file or directory an improbable filename @@ -152,6 +163,7 @@ bash: line 1: .: cwd-filename: file not found bash: line 1: .: cwd-filename: file not found file in the current directory file in the current directory + source1.sub AVAR foo foo @@ -162,12 +174,13 @@ AVAR foo declare -x foo="" declare -x FOO="\$\$" -./builtins.tests: line 242: declare: FOO: not found +./builtins.tests: line 251: declare: FOO: not found declare -x FOO="\$\$" ok ok -./builtins.tests: line 274: kill: 4096: invalid signal specification +./builtins.tests: line 283: kill: 4096: invalid signal specification 1 + builtins2.sub a\n\n\nb a @@ -175,9 +188,11 @@ a b -p a b c + builtins3.sub before: f = 4 inside after: f = 8 bar = 4 + builtins4.sub declare -a c declare -A d declare -a c=([0]="4") @@ -188,6 +203,7 @@ declare -a c=([0]="1" [1]="2" [2]="3") declare -a c=([0]="1" [1]="2" [2]="3") unset unset + builtins5.sub assoc 1 unset array 1 unset assoc 2 unset @@ -220,6 +236,7 @@ scalar: 0 scalar: 1 scalar: 0 scalar: 0 + builtins6.sub all set: one two @@ -261,6 +278,7 @@ f2 () funcs unset: one-two two-two + builtins7.sub bash: line 1: notthere: No such file or directory one bash: line 1: notthere: No such file or directory @@ -297,6 +315,7 @@ type + command -p -- command -v type type + set +x + builtins8.sub u=rw,g=rx,o=rx u=r,g=rx,o=rx u=rwx,g=rwx,o= @@ -315,6 +334,7 @@ u=rwx,g=rx,o=rx u=rwx,g=rx,o=rx u=rwx,g=rx,o=rx u=rwx,g=rx,o=x + builtins9.sub hash: hash table empty ./builtins9.sub: line 19: hash: notthere: not found 1 @@ -333,6 +353,7 @@ builtin hash -p /nosuchdir/nosuchfile cat found ./builtins9.sub: line 52: hash: /: Is a directory builtin hash -p /nosuchfile cat + builtins10.sub ./builtins10.sub: line 17: help: -x: invalid option help: usage: help [-dms] [pattern ...] These shell commands are defined internally. Type `help' to see this list. @@ -475,6 +496,7 @@ A star (*) next to a name means that the command is disabled. hash [-lr] [-p pathname] [-dt] [name > { COMMANDS ; } help [-dms] [pattern ...] ./builtins10.sub: line 39: help: no help topics match `bash'. Try `help help' or `man -k bash' or `info bash'. + builtins11.sub unlimited unlimited ./builtins11.sub: line 27: ulimit: +1999: invalid number @@ -483,6 +505,7 @@ unlimited ./builtins11.sub: line 37: ulimit: -g: invalid option ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPRT] [limit] ./builtins11.sub: line 39: ulimit: max user processes: cannot modify limit: Operation not permitted + builtins12.sub /tmp /bin /tmp /bin /bin /tmp @@ -502,5 +525,5 @@ popd: usage: popd [-n] [+N | -N] ./builtins12.sub: line 36: popd: +8: directory stack index out of range /tmp / / -./builtins.tests: line 325: exit: status: numeric argument required +./builtins.tests: line 334: exit: status: numeric argument required after non-numeric arg to exit: 2 diff --git a/tests/builtins.tests b/tests/builtins.tests index 1d6d9a4b..fccb4dd7 100644 --- a/tests/builtins.tests +++ b/tests/builtins.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions + # tests for miscellaneous builtins not tested elsewhere set +p set +o posix @@ -164,18 +166,22 @@ unset -v SFILE AVAR=AVAR +printf '\tsource1.sub\n' . ./source1.sub AVAR=foo . ./source1.sub +printf '\tsource2.sub\n' . ./source2.sub echo $? +printf '\tsource3.sub\n' set -- a b c . ./source3.sub # make sure source with arguments does not change the shell's positional # parameters, but that the sourced file sees the arguments as its # positional parameters +printf '\tsource3.sub\n' echo "$@" . ./source3.sub x y z echo "$@" @@ -184,6 +190,7 @@ echo "$@" # should be reflected in the calling shell's positional parameters. this # also tests one of the shopt options that controls source using $PATH to # find the script +printf '\tsource4.sub\n' echo "$@" shopt -u sourcepath . source4.sub @@ -191,29 +198,31 @@ echo "$@" # this is complicated when the sourced scripts gets its own positional # parameters from arguments to `.' +printf '\tsource4.sub\n' set -- a b c echo "$@" . source4.sub x y z echo "$@" # test out cd and $CDPATH -${THIS_SH} ./builtins1.sub +test_runsub ./builtins1.sub # test behavior of `.' when given a non-existent file argument -${THIS_SH} ./source5.sub +test_runsub ./source5.sub # test bugs in sourcing non-regular files, fixed post-bash-3.2 -${THIS_SH} ./source6.sub +test_runsub ./source6.sub # test bugs with source called from multiline aliases and other contexts -${THIS_SH} ./source7.sub +test_runsub ./source7.sub # test source/. -p path -${THIS_SH} ./source8.sub +test_runsub ./source8.sub # in posix mode, assignment statements preceding special builtins are # reflected in the shell environment. `.' and `eval' need special-case # code. +printf '\tsource1.sub\n' set -o posix echo $AVAR AVAR=foo . ./source1.sub @@ -284,37 +293,37 @@ y=$(kill -l SIGINT) unset -v x y # test behavior of shopt xpg_echo -${THIS_SH} ./builtins2.sub +test_runsub ./builtins2.sub # test behavior of declare -g -${THIS_SH} ./builtins3.sub +test_runsub ./builtins3.sub # test behavior of using declare to create variables without assigning values -${THIS_SH} ./builtins4.sub +test_runsub ./builtins4.sub # test behavior of set and unset array variables -${THIS_SH} ./builtins5.sub +test_runsub ./builtins5.sub # test behavior of unset builtin with -f and -v options -${THIS_SH} ./builtins6.sub +test_runsub ./builtins6.sub # test behavior of command builtin after changing it to a pseudo-keyword -${THIS_SH} ./builtins7.sub +test_runsub ./builtins7.sub # POSIX complete symbolic umask tests -${THIS_SH} ./builtins8.sub +test_runsub ./builtins8.sub # hash tests -${THIS_SH} ./builtins9.sub +test_runsub ./builtins9.sub # help tests -${THIS_SH} ./builtins10.sub +test_runsub ./builtins10.sub # ulimit tests -${THIS_SH} ./builtins11.sub +test_runsub ./builtins11.sub # pushd/popd/dirs -${THIS_SH} ./builtins12.sub +test_runsub ./builtins12.sub shift 0 # succeeds silently diff --git a/tests/case.right b/tests/case.right index 3ff3eaf5..230bc6a0 100644 --- a/tests/case.right +++ b/tests/case.right @@ -5,7 +5,7 @@ retest and match no more clauses 1.0 -./case.tests: line 42: xx: readonly variable +./case.tests: line 44: xx: readonly variable 1.1 matches 1 no @@ -18,6 +18,7 @@ esac unset word ok 1 unset word ok 2 unset word ok 3 + case1.sub ok 1 ok 2 ok 3 @@ -29,6 +30,7 @@ ok 8 ok 9 mysterious 1 mysterious 2 + case2.sub argv[1] = <\a\b\c\^A\d\e\f> argv[1] = <\a\b\c\^A\d\e\f> argv[1] = @@ -40,6 +42,7 @@ ok 5 ok 6 ok 7 ok 8 + case3.sub --- testing: soh ok1ok2ok3ok4ok5 ok1ok2ok3ok4ok5 @@ -64,3 +67,4 @@ ok1ok2ok3ok4ok5 ok1ok2ok3ok4ok5 ok1ok2ok3ok4ok5 ok1ok2ok3ok4ok5 + case4.sub diff --git a/tests/case.tests b/tests/case.tests index 2bb0922d..4b73bfba 100644 --- a/tests/case.tests +++ b/tests/case.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# case foo in bar) echo skip ;; foo) echo fallthrough ;& @@ -76,7 +78,7 @@ unset|$unset) echo unset word ok 3 ;; esac # tests of quote removal and pattern matching -${THIS_SH} ./case1.sub -${THIS_SH} ./case2.sub -${THIS_SH} ./case3.sub -${THIS_SH} ./case4.sub +test_runsub ./case1.sub +test_runsub ./case2.sub +test_runsub ./case3.sub +test_runsub ./case4.sub diff --git a/tests/comsub-eof.right b/tests/comsub-eof.right index c6a4c9ef..9069eeec 100644 --- a/tests/comsub-eof.right +++ b/tests/comsub-eof.right @@ -1,19 +1,26 @@ + comsub-eof0.sub ./comsub-eof0.sub: line 4: warning: here-document at line 2 delimited by end-of-file (wanted `EOF') hi ./comsub-eof0.sub: line 11: warning: here-document at line 9 delimited by end-of-file (wanted `EOF') hi + comsub-eof1.sub hi + comsub-eof2.sub ./comsub-eof2.sub: line 2: warning: here-document at line 1 delimited by end-of-file (wanted `EOF') hi + comsub-eof3.sub ./comsub-eof3.sub: line 4: warning: here-document at line 1 delimited by end-of-file (wanted `EOF') ./comsub-eof3.sub: line 5: unexpected EOF while looking for matching `)' + comsub-eof4.sub ./comsub-eof4.sub: line 3: warning: here-document at line 1 delimited by end-of-file (wanted `EOF') contents + comsub-eof5.sub ./comsub-eof5.sub: line 4: warning: here-document at line 2 delimited by end-of-file (wanted `)') hi ./comsub-eof5.sub: line 9: warning: here-document at line 7 delimited by end-of-file (wanted `EOF') hi ./comsub-eof5.sub: line 15: warning: here-document at line 13 delimited by end-of-file (wanted `)') hi + comsub-eof6.sub ./comsub-eof6.sub: command substitution: line 3: unexpected EOF while looking for matching `)' diff --git a/tests/comsub-eof.tests b/tests/comsub-eof.tests index 398746aa..b0ad93c3 100644 --- a/tests/comsub-eof.tests +++ b/tests/comsub-eof.tests @@ -1,13 +1,15 @@ -${THIS_SH} ./comsub-eof0.sub +. ./test-aux-functions -${THIS_SH} ./comsub-eof1.sub +test_runsub ./comsub-eof0.sub -${THIS_SH} ./comsub-eof2.sub +test_runsub ./comsub-eof1.sub -${THIS_SH} ./comsub-eof3.sub +test_runsub ./comsub-eof2.sub -${THIS_SH} ./comsub-eof4.sub +test_runsub ./comsub-eof3.sub -${THIS_SH} ./comsub-eof5.sub +test_runsub ./comsub-eof4.sub -${THIS_SH} ./comsub-eof6.sub +test_runsub ./comsub-eof5.sub + +test_runsub ./comsub-eof6.sub diff --git a/tests/comsub-posix.right b/tests/comsub-posix.right index ce606f8f..c3b7f718 100644 --- a/tests/comsub-posix.right +++ b/tests/comsub-posix.right @@ -59,8 +59,10 @@ here-doc with \() here-doc terminated with a parenthesis ' # or a single back- or doublequote line terminated with a backslash + comsub-posix1.sub ./comsub-posix1.sub: line 1: syntax error near unexpected token `)' ./comsub-posix1.sub: line 1: `echo $( if x; then echo foo )' + comsub-posix2.sub swap32_posix is a function swap32_posix () { @@ -76,6 +78,8 @@ swap32_posix () )); done } + comsub-posix3.sub + comsub-posix5.sub bash: -c: line 1: syntax error near unexpected token `done' while looking for matching `)' bash: -c: line 1: `: $(case x in x) ;; x) done esac)' bash: -c: line 1: syntax error near unexpected token `done' while looking for matching `)' @@ -86,6 +90,7 @@ bash: -c: line 1: syntax error near unexpected token `in' while looking for matc bash: -c: line 1: `: $(case x in esac|in) foo;; esac)' bash: -c: line 1: syntax error near unexpected token `done' while looking for matching `)' bash: -c: line 1: `: $(case x in x) ;; x) done)' + comsub-posix6.sub case: -c: line 3: syntax error near unexpected token `esac' while looking for matching `)' case: -c: line 3: `$( esac ; bar=foo ; echo "$bar")) echo bad 2;;' ok 2 diff --git a/tests/comsub-posix.tests b/tests/comsub-posix.tests index ab7cd295..7eaa0fb7 100644 --- a/tests/comsub-posix.tests +++ b/tests/comsub-posix.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# : ${HOME:=/} # works right @@ -233,13 +235,13 @@ echo $( echo line terminated with a backslash # \ ) -${THIS_SH} ./comsub-posix1.sub -${THIS_SH} ./comsub-posix2.sub -${THIS_SH} ./comsub-posix3.sub +test_runsub ./comsub-posix1.sub +test_runsub ./comsub-posix2.sub +test_runsub ./comsub-posix3.sub -#${THIS_SH} ./comsub-posix4.sub -${THIS_SH} ./comsub-posix5.sub -${THIS_SH} ./comsub-posix6.sub +#test_runsub ./comsub-posix4.sub +test_runsub ./comsub-posix5.sub +test_runsub ./comsub-posix6.sub # produced a parse error through bash-4.0-beta2 : $(echo foo)" diff --git a/tests/comsub.right b/tests/comsub.right index 5c856400..fba79392 100644 --- a/tests/comsub.right +++ b/tests/comsub.right @@ -1,4 +1,4 @@ -./comsub.tests: line 19: hijkl: command not found +./comsub.tests: line 21: hijkl: command not found argv[1] = argv[2] = argv[1] = @@ -25,6 +25,7 @@ blank ---- blank ---- blank ---- func: v = comsub + comsub1.sub #esac a ok 1 @@ -35,10 +36,12 @@ ok 5 ok 6 xyz ok 7 + comsub2.sub \/tmp\/foo\/bar /tmp/foo/bar /tmp/foo/bar /tmp/foo/bar + comsub3.sub 1 2 3 @@ -55,12 +58,14 @@ b c 1 2 + comsub4.sub d \ g d \ g d \ g + comsub5.sub ok 1 ok 2 ok 3 @@ -71,6 +76,7 @@ ok 7 ok 9 ok 8 ok 8 + comsub6.sub Mon Aug 29 20:03:02 EDT 2022 post foo Mon Aug 29 20:03:02 EDT 2022 @@ -82,6 +88,7 @@ Mon Aug 29 20:03:02 EDT 2022 hey after x ./comsub6.sub: line 40: syntax error near unexpected token `)' ./comsub6.sub: line 40: `math1)' + comsub7.sub 123 123 0 diff --git a/tests/comsub.tests b/tests/comsub.tests index b4ae69b2..2bbdd89e 100644 --- a/tests/comsub.tests +++ b/tests/comsub.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# # command substution parsing tests TABSIZE=`grep -v '^[ #]' $CAPS argv[1] = <> aa,bb JOBaa bb cc ddCONTROL -./comsub2.tests: line 68: p: command not found +./comsub2.tests: line 69: p: command not found NOTFOUND -./comsub2.tests: line 75: p: command not found -./comsub2.tests: line 75: p: command not found +./comsub2.tests: line 76: p: command not found +./comsub2.tests: line 76: p: command not found expand_aliases off expand_aliases off outside: -./comsub2.tests: line 79: alias: p: not found +./comsub2.tests: line 80: alias: p: not found alias e='echo inside redefine' expand_aliases off 1 @@ -34,7 +34,7 @@ expand_aliases on 2 expand_aliases on outside: -./comsub2.tests: line 89: alias: p: not found +./comsub2.tests: line 90: alias: p: not found expand_aliases on 1 xx @@ -62,6 +62,7 @@ one two 42 42 42 + comsub21.sub 123 123 0 @@ -75,6 +76,7 @@ Mon Aug 29 20:03:02 EDT 2022 123 before 123 in for 123 + comsub22.sub outside before: value inside before: value inside after: funsub @@ -82,6 +84,7 @@ inside: after false xxx outside after: funsub =====posix mode===== outside before: value + comsub23.sub . declare -a a=([0]="1" [1]="2" [2]="3" [3]="4") declare -- int="2" @@ -104,6 +107,7 @@ uname after arith for 1) a[${ break;}] #? after select + comsub24.sub a b c == 1 2 3 == 1 2 3 before return @@ -115,6 +119,7 @@ declare -- IFS=" " *??? *??? yyy zzzz + comsub25.sub argv[1] = argv[1] = argv[1] = @@ -178,6 +183,7 @@ argv[1] = argv[2] = argv[1] = argv[1] = + comsub26.sub inside1-inside2-outside BEFOREAA BB diff --git a/tests/comsub2.tests b/tests/comsub2.tests index 73d378ff..26d822fd 100644 --- a/tests/comsub2.tests +++ b/tests/comsub2.tests @@ -11,7 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - +. ./test-aux-functions +# # initial set of tests for ${Ccommand; } nofork command substitution # basic functionality @@ -145,9 +146,9 @@ echo $(( ${ echo 14 + 18; }+ 10)) echo ${ echo $(( 24+18 )); } # alias expansion and nested funsubs in other constructs -${THIS_SH} ./comsub21.sub -${THIS_SH} ./comsub22.sub -${THIS_SH} ./comsub23.sub -${THIS_SH} ./comsub24.sub -${THIS_SH} ./comsub25.sub -${THIS_SH} ./comsub26.sub +test_runsub ./comsub21.sub +test_runsub ./comsub22.sub +test_runsub ./comsub23.sub +test_runsub ./comsub24.sub +test_runsub ./comsub25.sub +test_runsub ./comsub26.sub diff --git a/tests/cond.right b/tests/cond.right index 48aba422..bf47b23a 100644 --- a/tests/cond.right +++ b/tests/cond.right @@ -12,7 +12,7 @@ returns: 0 returns: 0 returns: 1 returns: 0 -./cond.tests: line 65: [[: X: integer expected +./cond.tests: line 66: [[: X: integer expected returns: 2 returns: 0 returns: 1 @@ -29,7 +29,7 @@ returns: 0 returns: 1 returns: 1 returns: 0 -./cond.tests: line 126: [[: 4+: arithmetic syntax error: operand expected (error token is "+") +./cond.tests: line 127: [[: 4+: arithmetic syntax error: operand expected (error token is "+") returns: 1 returns: 0 returns: 0 @@ -60,6 +60,7 @@ ok c3 ok c4 ok c5 ok c6 + cond-regexp1.sub match 1 match 2 match 3 @@ -84,6 +85,7 @@ match control-a 2 match control-a 3 match control-a 4 match control-a 5 + cond-regexp2.sub ok 1 ok 2 ok 3 @@ -97,6 +99,7 @@ ok 9 ok 10 ok 11 ok 12 + cond-regexp3.sub argv[1] = <\^?> 0 1 @@ -148,6 +151,7 @@ ok 5 ok 6 ok 7 ok 8 + cond-error1.sub bash: -c: line 1: unexpected token `EOF', expected `)' bash: -c: line 2: syntax error: unexpected end of file from `[[' command on line 1 bash: -c: line 1: unexpected EOF while looking for `]]' @@ -181,6 +185,7 @@ bash: -c: line 1: syntax error near `<' bash: -c: line 1: `[[ -n < ]]' ERR: 22: -[[ -n $unset ]]- failed ERR: 28: -func- failed + cond-xtrace1.sub + [[ -t X ]] ./cond-xtrace1.sub: line 6: [[: X: integer expected + [[ '' > 7 ]] diff --git a/tests/cond.tests b/tests/cond.tests index 110f702f..19a9ac53 100644 --- a/tests/cond.tests +++ b/tests/cond.tests @@ -11,6 +11,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions # # the test/[ code is tested elsewhere, and the [[...]] just uses the same # code. this tests the special features of [[...]] @@ -240,9 +241,9 @@ var=$'ab\001c' [[ $var == a* ]] && echo ok c5 [[ $var == $'ab\001'* ]] && echo ok c6 -${THIS_SH} ./cond-regexp1.sub -${THIS_SH} ./cond-regexp2.sub -${THIS_SH} ./cond-regexp3.sub +test_runsub ./cond-regexp1.sub +test_runsub ./cond-regexp2.sub +test_runsub ./cond-regexp3.sub -${THIS_SH} ./cond-error1.sub -${THIS_SH} ./cond-xtrace1.sub +test_runsub ./cond-error1.sub +test_runsub ./cond-xtrace1.sub diff --git a/tests/dollar-at-star b/tests/dollar-at-star index e7b24eed..ff575895 100755 --- a/tests/dollar-at-star +++ b/tests/dollar-at-star @@ -11,7 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - +. ./test-aux-functions +# # first, let's start with the basics recho "$@" @@ -240,96 +241,96 @@ esac # tests for the effect of quoting $* and $@ in an assignment context (plus # arrays) -- bugs through bash 4.2 -${THIS_SH} ./dollar-at-star1.sub +test_runsub ./dollar-at-star1.sub # more tests for expanding $@ and $* in a context where there is no word # splitting -${THIS_SH} ./dollar-at-star2.sub -${THIS_SH} ./dollar-at-star3.sub -${THIS_SH} ./dollar-at-star4.sub -${THIS_SH} ./dollar-at-star5.sub -${THIS_SH} ./dollar-at-star6.sub -${THIS_SH} ./dollar-at-star7.sub +test_runsub ./dollar-at-star2.sub +test_runsub ./dollar-at-star3.sub +test_runsub ./dollar-at-star4.sub +test_runsub ./dollar-at-star5.sub +test_runsub ./dollar-at-star6.sub +test_runsub ./dollar-at-star7.sub # tests for expansions of $@ and ${a[@]} (vs. $* and ${a[*]}) on the RHS of # assignment statements with non-default IFS: $@ expands to args or array # members separated by spaces -${THIS_SH} ./dollar-at-star8.sub +test_runsub ./dollar-at-star8.sub # more tests of the expansions of $@ and $* (and their array equivalents) # with different values for IFS -${THIS_SH} ./dollar-at-star9.sub +test_runsub ./dollar-at-star9.sub # tests for expansions of "$*" and "$@" and their array equivalents when $1 == '' # and we're using the POSIX word expansions -${THIS_SH} ./dollar-at-star10.sub -${THIS_SH} ./dollar-at-star11.sub +test_runsub ./dollar-at-star10.sub +test_runsub ./dollar-at-star11.sub # tests for special expansion of "$*" and "${array[*]}" when used with other # expansions -- bugs through bash-2.05b -${THIS_SH} ./dollar-star1.sub +test_runsub ./dollar-star1.sub # tests for expansion of "$@" on rhs of things like ${param:+word}. Bugs # though bash-2.05b -${THIS_SH} ./dollar-at1.sub +test_runsub ./dollar-at1.sub # tests for expansion of other variables in double-quoted strings containing # $@. Bugs through bash-2.05b -${THIS_SH} ./dollar-at2.sub +test_runsub ./dollar-at2.sub # tests for various expansions of $* in different contexts -- word split, # no splitting, etc. when $IFS is NUL -${THIS_SH} ./dollar-star2.sub +test_runsub ./dollar-star2.sub # tests for expansions of "${array[*]}" and "${array[@]}" when $IFS is not the # default and the array contains null elements -${THIS_SH} ./dollar-star3.sub +test_runsub ./dollar-star3.sub # test for set -u and expansions of $@ when there are no positional parameters -${THIS_SH} ./dollar-at3.sub +test_runsub ./dollar-at3.sub # test for set -u and expansions of $* when there are no positional parameters -${THIS_SH} ./dollar-star4.sub +test_runsub ./dollar-star4.sub # tests for expansions of $* when IFS is null -${THIS_SH} ./dollar-star5.sub +test_runsub ./dollar-star5.sub # tests for inappropriate word splitting through bash-4.2 -${THIS_SH} ./dollar-at4.sub +test_runsub ./dollar-at4.sub # tests for problems with "$@" preceded and followed by other quoted expansions # through bash-4.2 -${THIS_SH} ./dollar-at5.sub +test_runsub ./dollar-at5.sub # tests for problems with "${@:1}" and other expansions with null entries # in positional parameters -${THIS_SH} ./dollar-at6.sub +test_runsub ./dollar-at6.sub # tests for expansions of $* when $1 == ""; problem through bash-4.2 -${THIS_SH} ./dollar-star6.sub +test_runsub ./dollar-star6.sub # tests for expansions of $* (unquoted) when IFS changes (e.g., ${IFS:=-}) # problem through bash-4.2 -${THIS_SH} ./dollar-star7.sub +test_runsub ./dollar-star7.sub # tests for expansions of $* (unquoted) when IFS is null and word splitting is # not going to be performed. # problem through bash-4.4 in some parameter expansion contexts -${THIS_SH} ./dollar-star8.sub +test_runsub ./dollar-star8.sub # tests for expansions of "$@" when there are no positional parameter or when # $1 == '' and the expansion is preceded by something that results in a quoted # null string -${THIS_SH} ./dollar-at7.sub +test_runsub ./dollar-at7.sub # tests for expansions of $* when in an assignment context (no splitting) and # IFS is null -${THIS_SH} ./dollar-star9.sub +test_runsub ./dollar-star9.sub # more tests for expansions of $* when not splitting with IFS set or unset and # null strings as the positional parameters -${THIS_SH} ./dollar-star10.sub +test_runsub ./dollar-star10.sub # tests for expansions of $* when IFS=$'\1' -${THIS_SH} ./dollar-star11.sub +test_runsub ./dollar-star11.sub exit 0 diff --git a/tests/dollar.right b/tests/dollar.right index afb74484..b3b142d9 100644 --- a/tests/dollar.right +++ b/tests/dollar.right @@ -95,6 +95,7 @@ ok 1 ok 2 ok 3 ok 4 + dollar-at-star1.sub var=${a[*]} ... one:::two:three:::four var="${a[*]}" ... one:::two:three:::four var=$* ... one:::two:three:::four @@ -103,6 +104,7 @@ var=${a[@]} ... one:::two three:::four var="${a[@]}" ... one:::two three:::four var=$@ ... one:::two three:::four var="$@" ... one:::two three:::four + dollar-at-star2.sub ok 1 ok 2 ok 3 @@ -156,6 +158,7 @@ ok at 6 ok at 7 ok at 8 ok at 9 + dollar-at-star3.sub argv[1] = argv[1] = argv[1] = @@ -169,6 +172,7 @@ argv[1] = argv[1] = <123 abc> <123 abc> + dollar-at-star4.sub a bc a b @@ -199,6 +203,7 @@ argv[1] = + dollar-at-star5.sub 0 0 1 @@ -232,6 +237,7 @@ argv[1] = <> variable argv[1] = <> dollar-at + dollar-at-star6.sub argv[1] = <'a'> argv[2] = <'b'> argv[3] = <'c'> @@ -269,6 +275,7 @@ argv[3] = <'c'> argv[1] = <'a'> argv[2] = <'b'> argv[3] = <'c'> + dollar-at-star7.sub |this| |is| |a| @@ -297,11 +304,13 @@ argv[3] = <'c'> |is| |a| |test| + dollar-at-star8.sub a1=a b c a,b,c a b c a,b,c a b c a,b,c a2=a b c a,b,c a b c a,b,c a b c a,b,c a3=a b c a,b,c a b c a,b,c a b c a,b,c a4=a b c a,b,c a b c a,b,c a b c a,b,c + dollar-at-star9.sub argv[1] = < > argv[1] = < > argv[1] = < > @@ -399,6 +408,7 @@ argv[1] = <^?> argv[1] = <^?> argv[1] = <> argv[1] = <> + dollar-at-star10.sub argv[1] = <> argv[1] = <> argv[1] = <> @@ -427,6 +437,7 @@ argv[1] = <> argv[1] = <> argv[1] = <> argv[1] = <> + dollar-at-star11.sub argv[1] = <> argv[1] = <> argv[1] = <> @@ -466,6 +477,7 @@ argv[1] = <> argv[1] = <> argv[1] = 1:1 + dollar-star1.sub xa|xb|xc xa|xb|xc a|b|c @@ -482,6 +494,7 @@ a|b|c a|b|c xa|xb|xc xa|xb|xc + dollar-at1.sub 3 3 3 @@ -490,12 +503,14 @@ xa|xb|xc 3 3 3 + dollar-at2.sub argv[1] = argv[1] = argv[2] = <2> argv[1] = argv[1] = argv[2] = <2> + dollar-star2.sub argv[1] = argv[1] = argv[1] = @@ -505,6 +520,7 @@ argv[1] = argv[2] = argv[1] = argv[1] = + dollar-star3.sub argv[1] = argv[1] = argv[2] = <> @@ -520,23 +536,27 @@ argv[1] = argv[2] = <> argv[3] = argv[4] = <> + dollar-at3.sub 0 bar after 1 after 2 + dollar-star4.sub 0 bar after 1 after 2 + dollar-star5.sub a b ab cd ok 1 ok 2 + dollar-at4.sub argv[1] = argv[2] = argv[1] = @@ -545,6 +565,7 @@ argv[3] = argv[4] = argv[1] = argv[1] = + dollar-at5.sub <1> <2> <3> <4> <5 1> <1 1> <2> <3> <4> <5> <11> <2> <3> <4> <51> @@ -596,6 +617,7 @@ ${@:2}c$1 c2 c3 #works as long as quoting omitted set y zcx c2 c3 0 declare -a c=([0]="y" [1]="zcx" [2]="c2" [3]="c3") + dollar-at6.sub argv[1] = <> argv[2] = argv[1] = <> @@ -617,6 +639,7 @@ argv[1] = <> argv[1] = <> argv[1] = <> argv[1] = <> + dollar-star6.sub argv[1] = argv[1] = argv[1] = @@ -629,6 +652,7 @@ argv[1] = argv[1] = argv[1] = argv[1] = + dollar-star7.sub after 1: IFS - argv[1] = @@ -645,6 +669,7 @@ argv[2] = argv[3] = argv[4] = argv[1] = + dollar-star8.sub <3> @@ -675,6 +700,7 @@ argv[1] = + dollar-at7.sub argv[1] = <1> argv[2] = <> argv[1] = <2> @@ -722,6 +748,7 @@ argv[1] = <1> argv[2] = <> argv[1] = <2> argv[2] = <> + dollar-star9.sub <12><12><12><12><12><12> <12><12><12><12><12><12> <12><'1''2'> @@ -742,6 +769,8 @@ argv[2] = <2> var=1 2 argv[1] = <1 2> argv[1] = <1 2> + dollar-star10.sub + dollar-star11.sub argv[1] = <^Aaa^Abb^Acc^A--^Add^A> argv[1] = <^A--^A> ok 1 diff --git a/tests/errors.right b/tests/errors.right index f46ebb11..ac56c508 100644 --- a/tests/errors.right +++ b/tests/errors.right @@ -1,145 +1,146 @@ unalias: usage: unalias [-a] name [name ...] -./errors.tests: line 31: alias: -x: invalid option +./errors.tests: line 33: alias: -x: invalid option alias: usage: alias [-p] [name[=value] ... ] -./errors.tests: line 32: unalias: -x: invalid option +./errors.tests: line 34: unalias: -x: invalid option unalias: usage: unalias [-a] name [name ...] -./errors.tests: line 33: alias: hoowah: not found -./errors.tests: line 34: unalias: hoowah: not found -./errors.tests: line 37: `1': not a valid identifier -./errors.tests: line 41: `f\1': not a valid identifier -./errors.tests: line 45: `invalid-name': not a valid identifier -./errors.tests: line 47: `f\1': not a valid identifier -./errors.tests: line 50: `1': not a valid identifier -./errors.tests: line 51: `f\1': not a valid identifier -./errors.tests: line 52: `invalid-name': not a valid identifier -./errors.tests: line 54: `1': not a valid identifier -./errors.tests: line 55: `f\1': not a valid identifier -./errors.tests: line 59: `$1': not a valid identifier +./errors.tests: line 35: alias: hoowah: not found +./errors.tests: line 36: unalias: hoowah: not found +./errors.tests: line 39: `1': not a valid identifier +./errors.tests: line 43: `f\1': not a valid identifier +./errors.tests: line 47: `invalid-name': not a valid identifier +./errors.tests: line 49: `f\1': not a valid identifier +./errors.tests: line 52: `1': not a valid identifier +./errors.tests: line 53: `f\1': not a valid identifier +./errors.tests: line 54: `invalid-name': not a valid identifier +./errors.tests: line 56: `1': not a valid identifier +./errors.tests: line 57: `f\1': not a valid identifier +./errors.tests: line 61: `$1': not a valid identifier declare -fr func -./errors.tests: line 76: func: readonly function -./errors.tests: line 79: unset: -x: invalid option +./errors.tests: line 78: func: readonly function +./errors.tests: line 81: unset: -x: invalid option unset: usage: unset [-f] [-v] [-n] [name ...] -./errors.tests: line 82: unset: func: cannot unset: readonly function -./errors.tests: line 85: declare: func: readonly function -./errors.tests: line 89: declare: -a: invalid option -./errors.tests: line 90: declare: -i: invalid option -./errors.tests: line 94: unset: XPATH: cannot unset: readonly variable -./errors.tests: line 100: unset: cannot simultaneously unset a function and a variable -./errors.tests: line 103: declare: -z: invalid option +./errors.tests: line 84: unset: func: cannot unset: readonly function +./errors.tests: line 87: declare: func: readonly function +./errors.tests: line 91: declare: -a: invalid option +./errors.tests: line 92: declare: -i: invalid option +./errors.tests: line 96: unset: XPATH: cannot unset: readonly variable +./errors.tests: line 102: unset: cannot simultaneously unset a function and a variable +./errors.tests: line 105: declare: -z: invalid option declare: usage: declare [-aAfFgiIlnrtux] [name[=value] ...] or declare -p [-aAfFilnrtux] [name ...] -./errors.tests: line 105: declare: `-z': not a valid identifier -./errors.tests: line 106: declare: `/bin/sh': not a valid identifier -./errors.tests: line 110: declare: cannot use `-f' to make functions -./errors.tests: line 113: exec: -i: invalid option +./errors.tests: line 107: declare: `-z': not a valid identifier +./errors.tests: line 108: declare: `/bin/sh': not a valid identifier +./errors.tests: line 112: declare: cannot use `-f' to make functions +./errors.tests: line 115: exec: -i: invalid option exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...] -./errors.tests: line 120: export: XPATH: not a function -./errors.tests: line 123: break: only meaningful in a `for', `while', or `until' loop -./errors.tests: line 124: continue: only meaningful in a `for', `while', or `until' loop -./errors.tests: line 127: shift: label: numeric argument required -./errors.tests: line 132: shift: too many arguments -./errors.tests: line 138: let: expression expected -./errors.tests: line 141: local: can only be used in a function -./errors.tests: line 144: logout: not login shell: use `exit' -./errors.tests: line 147: hash: notthere: not found -./errors.tests: line 150: hash: -v: invalid option +./errors.tests: line 122: export: XPATH: not a function +./errors.tests: line 125: break: only meaningful in a `for', `while', or `until' loop +./errors.tests: line 126: continue: only meaningful in a `for', `while', or `until' loop +./errors.tests: line 129: shift: label: numeric argument required +./errors.tests: line 134: shift: too many arguments +./errors.tests: line 140: let: expression expected +./errors.tests: line 143: local: can only be used in a function +./errors.tests: line 146: logout: not login shell: use `exit' +./errors.tests: line 149: hash: notthere: not found +./errors.tests: line 152: hash: -v: invalid option hash: usage: hash [-lr] [-p pathname] [-dt] [name ...] -./errors.tests: line 153: hash: -d: option requires an argument -./errors.tests: line 157: hash: hashing disabled -./errors.tests: line 160: unset: [-2]: bad array subscript -./errors.tests: line 164: AA: readonly variable -./errors.tests: line 168: AA: readonly variable -./errors.tests: line 176: shift: 5: shift count out of range -./errors.tests: line 177: shift: -2: shift count out of range +./errors.tests: line 155: hash: -d: option requires an argument +./errors.tests: line 159: hash: hashing disabled +./errors.tests: line 162: unset: [-2]: bad array subscript +./errors.tests: line 166: AA: readonly variable +./errors.tests: line 170: AA: readonly variable ./errors.tests: line 178: shift: 5: shift count out of range ./errors.tests: line 179: shift: -2: shift count out of range -./errors.tests: line 182: shopt: no_such_option: invalid shell option name -./errors.tests: line 183: shopt: no_such_option: invalid shell option name -./errors.tests: line 184: shopt: no_such_option: invalid option name -./errors.tests: line 187: umask: 09: octal number out of range -./errors.tests: line 188: umask: `:': invalid symbolic mode character -./errors.tests: line 189: umask: `:': invalid symbolic mode operator -./errors.tests: line 192: umask: -i: invalid option +./errors.tests: line 180: shift: 5: shift count out of range +./errors.tests: line 181: shift: -2: shift count out of range +./errors.tests: line 184: shopt: no_such_option: invalid shell option name +./errors.tests: line 185: shopt: no_such_option: invalid shell option name +./errors.tests: line 186: shopt: no_such_option: invalid option name +./errors.tests: line 189: umask: 09: octal number out of range +./errors.tests: line 190: umask: `:': invalid symbolic mode character +./errors.tests: line 191: umask: `:': invalid symbolic mode operator +./errors.tests: line 194: umask: -i: invalid option umask: usage: umask [-p] [-S] [mode] -./errors.tests: line 196: umask: `p': invalid symbolic mode character -./errors.tests: line 205: VAR: readonly variable -./errors.tests: line 208: declare: VAR: readonly variable -./errors.tests: line 209: declare: VAR: readonly variable -./errors.tests: line 211: declare: unset: not found -./errors.tests: line 214: VAR: readonly variable +./errors.tests: line 198: umask: `p': invalid symbolic mode character +./errors.tests: line 207: VAR: readonly variable +./errors.tests: line 210: declare: VAR: readonly variable +./errors.tests: line 211: declare: VAR: readonly variable +./errors.tests: line 213: declare: unset: not found +./errors.tests: line 216: VAR: readonly variable comsub: -c: line 1: syntax error near unexpected token `)' comsub: -c: line 1: `: $( for z in 1 2 3; do )' comsub: -c: line 1: syntax error near unexpected token `done' while looking for matching `)' comsub: -c: line 1: `: $( for z in 1 2 3; done )' -./errors.tests: line 221: cd: HOME not set -./errors.tests: line 222: cd: /tmp/xyz.bash: No such file or directory -./errors.tests: line 224: cd: OLDPWD not set -./errors.tests: line 225: cd: /bin/sh: Not a directory -./errors.tests: line 227: cd: /tmp/cd-notthere: No such file or directory -./errors.tests: line 229: cd: too many arguments +./errors.tests: line 223: cd: HOME not set +./errors.tests: line 224: cd: /tmp/xyz.bash: No such file or directory +./errors.tests: line 226: cd: OLDPWD not set +./errors.tests: line 227: cd: /bin/sh: Not a directory +./errors.tests: line 229: cd: /tmp/cd-notthere: No such file or directory +./errors.tests: line 231: cd: too many arguments bash: line 1: PWD: readonly variable 1 bash: line 1: OLDPWD: readonly variable 1 -./errors.tests: line 236: .: filename argument required +./errors.tests: line 238: .: filename argument required .: usage: . [-p path] filename [arguments] -./errors.tests: line 237: source: filename argument required +./errors.tests: line 239: source: filename argument required source: usage: source [-p path] filename [arguments] -./errors.tests: line 240: .: -i: invalid option +./errors.tests: line 242: .: -i: invalid option .: usage: . [-p path] filename [arguments] -./errors.tests: line 243: set: -q: invalid option +./errors.tests: line 245: set: -q: invalid option set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...] -./errors.tests: line 246: enable: sh: not a shell builtin -./errors.tests: line 246: enable: bash: not a shell builtin -./errors.tests: line 249: shopt: cannot set and unset shell options simultaneously -./errors.tests: line 252: read: -x: invalid option +./errors.tests: line 248: enable: sh: not a shell builtin +./errors.tests: line 248: enable: bash: not a shell builtin +./errors.tests: line 251: shopt: cannot set and unset shell options simultaneously +./errors.tests: line 254: read: -x: invalid option read: usage: read [-Eers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...] -./errors.tests: line 255: read: var: invalid timeout specification -./errors.tests: line 258: read: `/bin/sh': not a valid identifier -./errors.tests: line 259: read: `/bin/sh': not a valid identifier -./errors.tests: line 260: read: `invalid-name': not a valid identifier -./errors.tests: line 263: VAR: readonly variable -./errors.tests: line 266: read: XX: invalid file descriptor specification -./errors.tests: line 267: read: 42: invalid file descriptor: Bad file descriptor -./errors.tests: line 270: mapfile: XX: invalid file descriptor specification -./errors.tests: line 271: mapfile: 42: invalid file descriptor: Bad file descriptor -./errors.tests: line 275: mapfile: empty array variable name -./errors.tests: line 276: mapfile: `invalid-var': not a valid identifier -./errors.tests: line 279: readonly: -x: invalid option +./errors.tests: line 257: read: var: invalid timeout specification +./errors.tests: line 260: read: `/bin/sh': not a valid identifier +./errors.tests: line 261: read: `/bin/sh': not a valid identifier +./errors.tests: line 262: read: `invalid-name': not a valid identifier +./errors.tests: line 265: VAR: readonly variable +./errors.tests: line 268: read: XX: invalid file descriptor specification +./errors.tests: line 269: read: 42: invalid file descriptor: Bad file descriptor +./errors.tests: line 272: mapfile: XX: invalid file descriptor specification +./errors.tests: line 273: mapfile: 42: invalid file descriptor: Bad file descriptor +./errors.tests: line 277: mapfile: empty array variable name +./errors.tests: line 278: mapfile: `invalid-var': not a valid identifier +./errors.tests: line 281: readonly: -x: invalid option readonly: usage: readonly [-aAf] [name[=value] ...] or readonly -p -./errors.tests: line 282: eval: -i: invalid option +./errors.tests: line 284: eval: -i: invalid option eval: usage: eval [arg ...] -./errors.tests: line 283: command: -i: invalid option +./errors.tests: line 285: command: -i: invalid option command: usage: command [-pVv] command [arg ...] -./errors.tests: line 286: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0") -./errors.tests: line 287: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0") -./errors.tests: line 290: trap: NOSIG: invalid signal specification -./errors.tests: line 293: trap: -s: invalid option +./errors.tests: line 288: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0") +./errors.tests: line 289: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0") +./errors.tests: line 292: trap: NOSIG: invalid signal specification +./errors.tests: line 295: trap: -s: invalid option trap: usage: trap [-Plp] [[action] signal_spec ...] -./errors.tests: line 299: return: can only `return' from a function or sourced script -./errors.tests: line 303: break: 0: loop count out of range -./errors.tests: line 307: continue: 0: loop count out of range -./errors.tests: line 312: builtin: -x: invalid option +./errors.tests: line 301: return: can only `return' from a function or sourced script +./errors.tests: line 305: break: 0: loop count out of range +./errors.tests: line 309: continue: 0: loop count out of range +./errors.tests: line 314: builtin: -x: invalid option builtin: usage: builtin [shell-builtin [arg ...]] -./errors.tests: line 315: builtin: bash: not a shell builtin -./errors.tests: line 319: bg: no job control -./errors.tests: line 320: fg: no job control +./errors.tests: line 317: builtin: bash: not a shell builtin +./errors.tests: line 321: bg: no job control +./errors.tests: line 322: fg: no job control kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec] -./errors.tests: line 324: kill: -s: option requires an argument -./errors.tests: line 326: kill: S: invalid signal specification -./errors.tests: line 328: kill: `': not a pid or valid job spec +./errors.tests: line 326: kill: -s: option requires an argument +./errors.tests: line 328: kill: S: invalid signal specification +./errors.tests: line 330: kill: `': not a pid or valid job spec kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec] -./errors.tests: line 332: kill: SIGBAD: invalid signal specification -./errors.tests: line 334: kill: BAD: invalid signal specification -./errors.tests: line 336: kill: `@12': not a pid or valid job spec -./errors.tests: line 339: unset: BASH_LINENO: cannot unset -./errors.tests: line 339: unset: BASH_SOURCE: cannot unset -./errors.tests: line 342: set: trackall: invalid option name -./errors.tests: line 343: set: -q: invalid option +./errors.tests: line 334: kill: SIGBAD: invalid signal specification +./errors.tests: line 336: kill: BAD: invalid signal specification +./errors.tests: line 338: kill: `@12': not a pid or valid job spec +./errors.tests: line 341: unset: BASH_LINENO: cannot unset +./errors.tests: line 341: unset: BASH_SOURCE: cannot unset +./errors.tests: line 344: set: trackall: invalid option name +./errors.tests: line 345: set: -q: invalid option set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...] -./errors.tests: line 344: set: -i: invalid option +./errors.tests: line 346: set: -i: invalid option set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...] -./errors.tests: line 348: xx: readonly variable +./errors.tests: line 350: xx: readonly variable 1 + errors1.sub ./errors1.sub: line 14: .: -i: invalid option .: usage: . [-p path] filename [arguments] ./errors1.sub: line 22: shift: -4: shift count out of range @@ -149,11 +150,14 @@ set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...] ./errors1.sub: line 29: break: -5: loop count out of range ./errors1.sub: line 30: continue: -5: loop count out of range after f + errors2.sub ./errors2.sub: line 3: ${$NO_SUCH_VAR}: bad substitution 1 + errors3.sub ./errors3.sub: line 5: no_such_file: No such file or directory TEST ./errors3.sub: line 7: no_such_file: No such file or directory + errors4.sub 1 2 ./errors4.sub: line 20: var: readonly variable @@ -170,14 +174,17 @@ after readonly assignment 3) 3 #? ./errors4.sub: line 40: var: readonly variable ./errors4.sub: line 45: break: x: numeric argument required + errors4.sub 1 2 ./errors4.sub: line 20: var: readonly variable + errors5.sub ./errors5.sub: line 6: array: unbound variable ./errors5.sub: line 7: array: unbound variable ./errors5.sub: line 8: array[7]: unbound variable ./errors5.sub: line 11: 7: unbound variable ./errors5.sub: line 12: 7: unbound variable + errors6.sub after 1: 1 after 2: 1 after 3: 1 @@ -201,6 +208,7 @@ unset ./errors6.sub: line 54: invalid-ident: invalid variable name ./errors6.sub: line 55: invalid-ident: invalid variable name ./errors6.sub: line 56: invalid-ident: invalid variable name + errors6.sub 4 array after 1: 0 @@ -221,6 +229,7 @@ unset ./errors6.sub: line 54: invalid-ident: invalid variable name ./errors6.sub: line 55: invalid-ident: invalid variable name ./errors6.sub: line 56: invalid-ident: invalid variable name + errors7.sub ./errors7.sub: line 21: x: readonly variable ./errors7.sub: line 21: notthere: command not found after no such command: 127 @@ -232,6 +241,7 @@ after special builtin: 0 ./errors7.sub: line 27: x: readonly variable ./errors7.sub: line 29: x: readonly variable ./errors7.sub: line 32: v: readonly variable + errors7.sub ./errors7.sub: line 21: x: readonly variable after no such command: 1 ./errors7.sub: line 23: x: readonly variable @@ -240,6 +250,7 @@ after non-special builtin: 1 ./errors7.sub: line 27: x: readonly variable ./errors7.sub: line 29: x: readonly variable ./errors7.sub: line 32: v: readonly variable + errors8.sub ./errors8.sub: eval: line 7: syntax error: unexpected end of file from `(' command on line 6 ok 1 ./errors8.sub: line 8: v: readonly variable @@ -257,12 +268,14 @@ ok 7 ./errors8.sub: line 17: .: -x: invalid option .: usage: . [-p path] filename [arguments] ok 8 + errors9.sub DEBUG ./errors9.sub: line 6: [[: ++: arithmetic syntax error: operand expected (error token is "+") DEBUG ./errors9.sub: line 8: ((: -- : arithmetic syntax error: operand expected (error token is "- ") DEBUG ./errors9.sub: line 10: ((: -- : arithmetic syntax error: operand expected (error token is "- ") + errors10.sub invalid numeric argument bash: line 1: exit: abcde: numeric argument required after exit: 2 @@ -302,6 +315,7 @@ errors: line 3: break: too many arguments after break: 2 errors: line 3: continue: too many arguments after continue: 2 + errors11.sub bash: line 1: readonly: `non-identifier': not a valid identifier after: 1 bash: line 1: export: `non-identifier': not a valid identifier @@ -330,6 +344,7 @@ bash: line 1: readonly: `AA[4]': not a valid identifier array: 1 sh: line 1: export: `AA[4]': not a valid identifier sh: line 1: readonly: `AA[4]': not a valid identifier + errors12.sub bash: -c: line 5: syntax error: unexpected end of file from `if' command on line 1 bash: -c: line 3: syntax error: unexpected end of file from `while' command on line 1 bash: -c: line 4: syntax error: unexpected end of file from `until' command on line 1 diff --git a/tests/errors.tests b/tests/errors.tests index d10935dc..45d6994e 100644 --- a/tests/errors.tests +++ b/tests/errors.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# # These should all be safe LC_ALL=C LC_CTYPE=C @@ -348,31 +350,34 @@ readonly xx=5 echo $((xx=5)) echo $? -${THIS_SH} ./errors1.sub -${THIS_SH} ./errors2.sub -${THIS_SH} ./errors3.sub -${THIS_SH} ./errors4.sub +test_runsub ./errors1.sub +test_runsub ./errors2.sub +test_runsub ./errors3.sub +test_runsub ./errors4.sub +printf '\terrors4.sub\n' ${THIS_SH} -o posix ./errors4.sub -${THIS_SH} ./errors5.sub +test_runsub ./errors5.sub -${THIS_SH} ./errors6.sub +test_runsub ./errors6.sub +printf '\terrors6.sub\n' THIS_SH="${THIS_SH} -o posix" ${THIS_SH} ./errors6.sub -${THIS_SH} ./errors7.sub +test_runsub ./errors7.sub +printf '\terrors7.sub\n' ${THIS_SH} -o posix ./errors7.sub -${THIS_SH} ./errors8.sub -${THIS_SH} ./errors9.sub +test_runsub ./errors8.sub +test_runsub ./errors9.sub # invalid numeric arguments and too many arguments -${THIS_SH} ./errors10.sub +test_runsub ./errors10.sub # invalid identifiers to readonly/export -${THIS_SH} ./errors11.sub +test_runsub ./errors11.sub # EOF when parsing compound commands -${THIS_SH} ./errors12.sub +test_runsub ./errors12.sub ${THIS_SH} -c 'return ; echo after return' bash ${THIS_SH} -o posix -c 'return ; echo after return' bash diff --git a/tests/exec.right b/tests/exec.right index bc30e5fc..d14f7fff 100644 --- a/tests/exec.right +++ b/tests/exec.right @@ -5,14 +5,14 @@ after exec1.sub with args: 0 after exec1.sub without args: 0 after exec1.sub: one two three -./execscript: line 37: notthere: command not found +./execscript: line 39: notthere: command not found 127 we would do something here with notthere /tmp/bash: notthere: No such file or directory 127 /bin/sh: /bin/sh: cannot execute binary file 126 -./execscript: line 64: /: Is a directory +./execscript: line 66: /: Is a directory 126 /: /: Is a directory 126 @@ -20,7 +20,7 @@ bash: line 1: exec: .: cannot execute: Is a directory posix-bash: line 1: exec: .: cannot execute: Is a directory bash: line 1: exec: .: cannot execute: Is a directory posix-bash: line 1: exec: .: cannot execute: Is a directory -./execscript: line 79: .: /: is a directory +./execscript: line 81: .: /: is a directory 1 126 0 @@ -37,26 +37,30 @@ trap -- 'echo USR1' SIGUSR1 trap -- 'rm -f x.sh x.output ; echo EXIT' EXIT USR1 EXIT -./execscript: line 103: notthere: command not found -127 ./execscript: line 105: notthere: command not found 127 ./execscript: line 107: notthere: command not found 127 -./execscript: line 113: notthere: command not found +./execscript: line 109: notthere: command not found 127 ./execscript: line 115: notthere: command not found 127 ./execscript: line 117: notthere: command not found 127 +./execscript: line 119: notthere: command not found +127 this is sh this is sh unset ok + exec2.sub 5 + exec4.sub + exec5.sub ./exec5.sub: line 4: exec: bash-notthere: not found 127 this is ohio-state + exec6.sub 0 1 1 @@ -78,8 +82,10 @@ this is ohio-state 0 1 0 + exec7.sub testb expand_aliases on + exec9.sub 1 1 1 @@ -88,6 +94,7 @@ expand_aliases on 0 0 0 + exec10.sub /usr/local/bin:/usr/GNU/bin:/usr/bin:/bin:. cannot find cat in $TMPDIR cannot find cat with empty $PATH @@ -95,6 +102,7 @@ PATH = /usr/local/bin:/usr/GNU/bin:/usr/bin:/bin:. cannot find cat in $TMPDIR with hash cannot find cat with empty $PATH with hash PATH = /usr/local/bin:/usr/GNU/bin:/usr/bin:/bin:. + exec11.sub trap -- 'echo foo $BASH_SUBSHELL' EXIT trap -- 'echo USR1 $BASHPID' SIGUSR1 between @@ -109,11 +117,17 @@ group pipeline: 1 EXIT-group.1 foo 0 after + exec12.sub exit code: 1 + exec12.sub exit code: 1 + exec12.sub exit code: 1 + exec12.sub exit code: 1 + exec12.sub exit code: 1 + exec12.sub exit code: 1 a b @@ -125,6 +139,7 @@ d c d e + exec13.sub x1 x1a x2 @@ -133,6 +148,7 @@ x2b x3 x3a x3b + exec14.sub WORKS done WORKS @@ -189,6 +205,7 @@ w x y z + exec15.sub Darwin x archive @@ -219,6 +236,7 @@ test sub3 1 done 42 + exec16.sub test invert reached subshell reached group @@ -247,6 +265,7 @@ reached AND-AND body reached OR-OR body reached AND-AND group reached OR-OR group + exec17.sub ./exec17.sub: line 26: exec: notthere: not found after failed exec: 127 ./exec17.sub: line 31: exec: notthere: not found diff --git a/tests/execscript b/tests/execscript index 15a9da8f..df5a0203 100644 --- a/tests/execscript +++ b/tests/execscript @@ -18,6 +18,8 @@ if [ $UID -eq 0 ]; then echo "execscript: the test suite should not be run as root" >&2 fi +. ./test-aux-functions + # this should succeed silently $cmd & @@ -129,13 +131,13 @@ echo ${PATH-unset} echo "echo ok" | ${THIS_SH} -t -${THIS_SH} ./exec2.sub +test_runsub ./exec2.sub echo $? -${THIS_SH} ./exec4.sub +test_runsub ./exec4.sub # try exec'ing a command that cannot be found in $PATH -${THIS_SH} ./exec5.sub +test_runsub ./exec5.sub # this was a bug in bash versions before bash-2.04 ${THIS_SH} -c 'cat /dev/null' >&- @@ -143,17 +145,17 @@ ${THIS_SH} -c 'cat /dev/null' >&- # checks for proper return values in subshell commands with inverted return # values -${THIS_SH} ./exec6.sub +test_runsub ./exec6.sub # checks for properly deciding what constitutes an executable file -${THIS_SH} ./exec7.sub +test_runsub ./exec7.sub HISTFILE= ${THIS_SH} --norc -i ${PWD}/exec8.sub -${THIS_SH} ./exec9.sub +test_runsub ./exec9.sub -${THIS_SH} ./exec10.sub -${THIS_SH} ./exec11.sub +test_runsub ./exec10.sub +test_runsub ./exec11.sub true | `echo true` & @@ -181,13 +183,13 @@ fi # problem with undoing redirections before running exit trap through bash-4.3 -${THIS_SH} ./exec12.sub false # function -${THIS_SH} ./exec12.sub command false -${THIS_SH} ./exec12.sub $FALSE +test_runsub ./exec12.sub false # function +test_runsub ./exec12.sub command false +test_runsub ./exec12.sub $FALSE -${THIS_SH} ./exec12.sub notfound -${THIS_SH} ./exec12.sub syntaxerror -${THIS_SH} ./exec12.sub nosuchcommand +test_runsub ./exec12.sub notfound +test_runsub ./exec12.sub syntaxerror +test_runsub ./exec12.sub nosuchcommand # problem with fork optimization in bash-4.4-alpha @@ -197,14 +199,14 @@ $THIS_SH -c 'echo A && /bin/echo B' $THIS_SH -c '/bin/echo c && echo d' $THIS_SH -c '/bin/echo c && /bin/echo d && echo e' -${THIS_SH} ./exec13.sub -${THIS_SH} ./exec14.sub +test_runsub ./exec13.sub +test_runsub ./exec14.sub # problems with fork optimization in bash-5.2 -${THIS_SH} ./exec15.sub +test_runsub ./exec15.sub # problems with set -e and inverting commands' return status -${THIS_SH} ./exec16.sub +test_runsub ./exec16.sub # test behavior of redirections when exec fails and does not exit the shell -${THIS_SH} ./exec17.sub +test_runsub ./exec17.sub diff --git a/tests/exp.right b/tests/exp.right index bc2dae5e..ac4e014a 100644 --- a/tests/exp.right +++ b/tests/exp.right @@ -155,6 +155,7 @@ a b c argv[1] = argv[2] = argv[3] = <> + exp1.sub argv[1] = <^?> argv[1] = <^?> argv[1] = <^?> @@ -180,20 +181,24 @@ argv[1] = <\^A^?> argv[1] = <\^A^?> argv[1] = <^\^A ^\^?> argv[1] = <^A ^_> + exp2.sub 0.net 0.net0 0.net 0.net 0.net + exp3.sub graph yes a a + exp4.sub val val val no arg passed + exp5.sub hello [0;31m\] ] @@ -202,6 +207,7 @@ hello hello eo + exp6.sub argv[1] = argv[1] = argv[1] = <^?> @@ -229,6 +235,7 @@ argv[1] = argv[2] = argv[1] = argv[2] = + exp7.sub argv[1] = <^A> argv[1] = <3> argv[2] = <^C> @@ -241,6 +248,7 @@ argv[1] = argv[1] = argv[2] = argv[1] = + exp8.sub argv[1] = argv[1] = declare -- var=$'x\001y\177z' @@ -258,6 +266,7 @@ declare -a array=([0]=$'x\001y\177z') argv[1] = declare -a array=([0]=$'x\001y\177z') declare -A array=([$'x\001y\177z']=$'a\242b\002c' ) + exp9.sub abc def ghi @@ -360,6 +369,7 @@ jkl [] [foo] [] + exp10.sub < A >< B >< A >< B > < A >< B >< A >< B > < A >< B >< a >< b > @@ -371,6 +381,7 @@ jkl < A >< B >< a >< b > < A >< B >< A >< B > < A >< B ><' A '><' B '> + exp11.sub argv[1] = <1> argv[2] = <2> argv[1] = <1> @@ -412,6 +423,7 @@ ok 6 ok 7 ok 8 ok 9 + exp12.sub argv[1] = argv[1] = argv[1] = @@ -425,6 +437,7 @@ cdefg abcdefg abcde abcdefg + exp13.sub foo declare -- a="foo" 7 diff --git a/tests/exp.tests b/tests/exp.tests index 8dc0a601..ca752fdc 100644 --- a/tests/exp.tests +++ b/tests/exp.tests @@ -19,6 +19,8 @@ # # Chet Ramey +. ./test-aux-functions + # # If you comment out the body of this function, you can do a diff against # `expansion-tests.right' to see if the shell is behaving correctly @@ -415,21 +417,16 @@ echo ${a//\?/ } ${THIS_SH} -c 'var=a:b: ; IFS=" :" ; recho $var""' bash -${THIS_SH} ./exp1.sub - -${THIS_SH} ./exp2.sub - -${THIS_SH} ./exp3.sub - -${THIS_SH} ./exp4.sub - -${THIS_SH} ./exp5.sub - -${THIS_SH} ./exp6.sub -${THIS_SH} ./exp7.sub -${THIS_SH} ./exp8.sub -${THIS_SH} ./exp9.sub -${THIS_SH} ./exp10.sub -${THIS_SH} ./exp11.sub -${THIS_SH} ./exp12.sub -${THIS_SH} ./exp13.sub +test_runsub ./exp1.sub +test_runsub ./exp2.sub +test_runsub ./exp3.sub +test_runsub ./exp4.sub +test_runsub ./exp5.sub +test_runsub ./exp6.sub +test_runsub ./exp7.sub +test_runsub ./exp8.sub +test_runsub ./exp9.sub +test_runsub ./exp10.sub +test_runsub ./exp11.sub +test_runsub ./exp12.sub +test_runsub ./exp13.sub diff --git a/tests/exportfunc.right b/tests/exportfunc.right index 32e26308..a0125b79 100644 --- a/tests/exportfunc.right +++ b/tests/exportfunc.right @@ -3,9 +3,12 @@ exportfunc ok 2 ./exportfunc.tests: line 37: cve7169-bad: No such file or directory ./exportfunc.tests: eval: line 44: syntax error: unexpected end of file from `{' command on line 42 ./exportfunc.tests: line 43: cve7169-bad2: No such file or directory + exportfunc1.sub ./exportfunc1.sub: line 14: maximum here-document count exceeded -./exportfunc.tests: line 72: HELLO_WORLD: No such file or directory -./exportfunc.tests: eval: line 83: unexpected EOF while looking for matching `}' + exportfunc2.sub +./exportfunc.tests: line 74: HELLO_WORLD: No such file or directory +./exportfunc.tests: eval: line 85: unexpected EOF while looking for matching `}' + exportfunc3.sub ./exportfunc3.sub: line 23: export: foo=bar: cannot export status: 1 equals-1 diff --git a/tests/exportfunc.tests b/tests/exportfunc.tests index 64eb38bb..a112eba5 100644 --- a/tests/exportfunc.tests +++ b/tests/exportfunc.tests @@ -44,9 +44,11 @@ eval 'X() { (a)>\' ; . ./bar 2>/dev/null rm -f cve7169-bad2 $TMPDIR/bar # CVE-2014-7186 +printf '\texportfunc1.sub\n' ${THIS_SH} ./exportfunc1.sub # CVE-2014-7187 +printf '\texportfunc2.sub\n' ${THIS_SH} ./exportfunc2.sub # CVE-2014-6277 @@ -90,4 +92,5 @@ unset -f foo env $'BASH_FUNC_#badname%%'=$'() { :; }\nfoo () { echo transform-4; } ' ${THIS_SH} -c 'foo' 2>/dev/null # tests of exported names +printf '\texportfunc3.sub\n' ${THIS_SH} ./exportfunc3.sub diff --git a/tests/extglob.right b/tests/extglob.right index e01a60fb..60e5aa0c 100644 --- a/tests/extglob.right +++ b/tests/extglob.right @@ -79,6 +79,7 @@ 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] = a,b + extglob1.sub a.c a.c a.c @@ -88,10 +89,12 @@ a.c ok 1 ok 2 ok 3 + extglob1a.sub a ab a ab a ab a + extglob3.sub *(.) a.log *(foo) @@ -104,6 +107,7 @@ a.log *(foo|bar).* a.log a.log + extglob4.sub .x .y .z a b c .x .y .z a b c @@ -113,7 +117,9 @@ a b c a b c .x .y .z a b c .x .y .z a b c + extglob5.sub * + extglob6.sub .b a .b a a .b @@ -124,6 +130,7 @@ a .b a .b .b .b + extglob7.sub dotglob: .a .foo bar @(.foo) .foo @@ -182,6 +189,7 @@ no dotglob: .a .foo bar ? . .. .a .foo * bar + extglob8.sub extglob off x extglob off diff --git a/tests/extglob.tests b/tests/extglob.tests index ef5d7793..74f3f37d 100644 --- a/tests/extglob.tests +++ b/tests/extglob.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# # test the ksh-like extended globbing features: [!@*?+](patlist) shopt -s extglob @@ -384,13 +386,13 @@ foo= foo=${foo/#*([.])} unset foo -${THIS_SH} ./extglob1.sub -${THIS_SH} ./extglob1a.sub -${THIS_SH} ./extglob3.sub -${THIS_SH} ./extglob4.sub -${THIS_SH} ./extglob5.sub -${THIS_SH} ./extglob6.sub -${THIS_SH} ./extglob7.sub -${THIS_SH} ./extglob8.sub +test_runsub ./extglob1.sub +test_runsub ./extglob1a.sub +test_runsub ./extglob3.sub +test_runsub ./extglob4.sub +test_runsub ./extglob5.sub +test_runsub ./extglob6.sub +test_runsub ./extglob7.sub +test_runsub ./extglob8.sub exit 0 diff --git a/tests/func.right b/tests/func.right index da718d21..30f3d8e2 100644 --- a/tests/func.right +++ b/tests/func.right @@ -38,6 +38,7 @@ zf () { echo this is zf } + func1.sub f is a function f () { @@ -118,6 +119,7 @@ testgrp () } 1>&2; echo testgrp-b } + func2.sub funca is a function funca () { @@ -141,6 +143,7 @@ foo-bar () { : } + func3.sub expect 5 10 5 10 expect 20 @@ -153,6 +156,7 @@ expect 2 40 2 40 expect 5 20 5 20 + func4.sub ./func4.sub: line 23: foo: maximum function nesting level exceeded (100) 1 after: f = 100 @@ -166,6 +170,7 @@ after FUNCNEST unset: f = 201 ./func4.sub: line 23: foo: maximum function nesting level exceeded (20) 1 after FUNCNEST assign: f = 38 + func5.sub ./func5.sub: line 31: `sys$read': not a valid identifier 11111 () { diff --git a/tests/func.tests b/tests/func.tests index 1a753af7..0a545da2 100644 --- a/tests/func.tests +++ b/tests/func.tests @@ -17,6 +17,8 @@ if [ -n "$funcs" ]; then unset -f $funcs fi +. ./test-aux-functions + a() { x=$((x - 1)) @@ -168,20 +170,20 @@ ${THIS_SH} -c 'type -t zf' ${THIS_SH} -c 'type zf' unset -f zf -${THIS_SH} ./func1.sub +test_runsub ./func1.sub # tests for functions whose bodies are not group commands, with and without # attached redirections -${THIS_SH} ./func2.sub +test_runsub ./func2.sub # test for some posix-specific function behavior -${THIS_SH} ./func3.sub +test_runsub ./func3.sub # FUNCNEST testing -${THIS_SH} ./func4.sub +test_runsub ./func4.sub # function naming restrictions -${THIS_SH} ./func5.sub +test_runsub ./func5.sub unset -f myfunction myfunction() { diff --git a/tests/getopts.right b/tests/getopts.right index f5a5262a..810d1003 100644 --- a/tests/getopts.right +++ b/tests/getopts.right @@ -2,34 +2,45 @@ getopts: usage: getopts optstring name [arg ...] 2 getopts: usage: getopts optstring name [arg ...] 2 -./getopts.tests: line 23: getopts: -a: invalid option +./getopts.tests: line 25: getopts: -a: invalid option getopts: usage: getopts optstring name [arg ...] + getopts1.sub -a specified -b bval specified remaining args: one two three + getopts1.sub -a specified -b bval specified remaining args: one two three four five six seven eight nine ten eleven twelve + getopts1.sub ./getopts1.sub: option requires an argument -- b Usage: ./getopts1.sub [-a] [-b value] args + getopts2.sub -a specified -c cval specified -d specified + getopts3.sub -a specified -b 3 specified remaining args: one two three four five + getopts4.sub -a specified -b bval specified remaining args: one two three + getopts4.sub -a specified -b bval specified remaining args: one two three + getopts4.sub ./getopts4.sub: error: option `b' requires an argument Usage: ./getopts4.sub [-a] [-b value] args + getopts4.sub ./getopts4.sub: error: illegal option character `c' Usage: ./getopts4.sub [-a] [-b value] args + getopts4.sub -a specified remaining args: -b bval one two three + getopts5.sub OPTERR=0 a here something else here @@ -45,22 +56,29 @@ something else here getop: OPTIND=5 OPTIND=3 OPTERR=0 + getopts6.sub -a specified remaining args: + getopts6.sub -a specified remaining args: + getopts6.sub -a specified remaining args: 0 + getopts7.sub ./getopts7.sub: line 17: getopts: `opt-var': not a valid identifier remaining args: + getopts8.sub opt: x opt: y opt: a opt: b opt: c opt: z + getopts9.sub $1 = a + getopts10.sub ./getopts10.sub: line 16: OPTARG: readonly variable OPTARG = x = ? unset x = ? diff --git a/tests/getopts.tests b/tests/getopts.tests index 06cc29a2..06d599a2 100644 --- a/tests/getopts.tests +++ b/tests/getopts.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# # getopts tests # this should fail getopts @@ -22,35 +24,35 @@ echo $? # used in error messages, but not yet getopts -a opts name -${THIS_SH} ./getopts1.sub -a -b bval one two three +test_runsub ./getopts1.sub -a -b bval one two three # make sure getopts works when there are more than 9 positional parameters -${THIS_SH} ./getopts1.sub -a -b bval one two three four five six seven eight nine ten eleven twelve -${THIS_SH} ./getopts1.sub -a -b +test_runsub ./getopts1.sub -a -b bval one two three four five six seven eight nine ten eleven twelve +test_runsub ./getopts1.sub -a -b -${THIS_SH} ./getopts2.sub -ad -c cval three four five +test_runsub ./getopts2.sub -ad -c cval three four five -${THIS_SH} ./getopts3.sub +test_runsub ./getopts3.sub # make sure that `-b bval' and `-bbval' are equivalent -${THIS_SH} ./getopts4.sub -a -b bval one two three -${THIS_SH} ./getopts4.sub -a -bbval one two three +test_runsub ./getopts4.sub -a -b bval one two three +test_runsub ./getopts4.sub -a -bbval one two three # this tests `silent' error reporting -${THIS_SH} ./getopts4.sub -a -b -${THIS_SH} ./getopts4.sub -a -c +test_runsub ./getopts4.sub -a -b +test_runsub ./getopts4.sub -a -c # make sure that `--' can be used to end the list of options -${THIS_SH} ./getopts4.sub -a -- -b bval one two three +test_runsub ./getopts4.sub -a -- -b bval one two three -${THIS_SH} ./getopts5.sub -a -c +test_runsub ./getopts5.sub -a -c -${THIS_SH} ./getopts6.sub -a -${THIS_SH} ./getopts6.sub -a -c -${THIS_SH} ./getopts6.sub -ac +test_runsub ./getopts6.sub -a +test_runsub ./getopts6.sub -a -c +test_runsub ./getopts6.sub -ac echo $? # this should be 2 -${THIS_SH} ./getopts7.sub -a +test_runsub ./getopts7.sub -a -${THIS_SH} ./getopts8.sub -${THIS_SH} ./getopts9.sub +test_runsub ./getopts8.sub +test_runsub ./getopts9.sub -${THIS_SH} ./getopts10.sub +test_runsub ./getopts10.sub diff --git a/tests/glob.right b/tests/glob.right index bde7e631..95e8f3b6 100644 --- a/tests/glob.right +++ b/tests/glob.right @@ -1,4 +1,6 @@ + glob1.sub foo/bar foobar/bar + glob2.sub ok 1 ok 2 ok 3 @@ -13,6 +15,7 @@ argv[1] = a\? argv[1] = @@ -71,6 +75,7 @@ a\? a\a + glob5.sub ./tmp/a/b/c ./tmp/a/b/c ./tmp/a/b/c ./tmp/a/b/c ./tmp/a/b/c ./tmp/a/b/c ./tmp/a/b/c @@ -99,6 +104,7 @@ argv[1] = <./tmp/> argv[1] = <\$foo> argv[2] = <\$foo> argv[1] = + glob6.sub <\.> *abc.c @@ -111,20 +117,25 @@ readable/\. searchable/. searchable/. searchable/. + glob7.sub 1: [qwe/qwe] 2: [qwe/ 3: [qwe/] 4: 5: [qwe/ 6: + glob8.sub a\*b a\*b* + glob9.sub é/* é/* + glob10.sub a aa b bb .a .aa .b .bb a aa b bb .a .aa .b .bb . .. .a .aa .b .bb + glob11.sub mailcheck.o make_cmd.o mksignames mksignames.o mksyntax mksyntax.dSYM mailcheck.o make_cmd.o mksignames mksignames.o mksyntax mksyntax.dSYM @@ -157,7 +168,7 @@ argv[2] = argv[3] = argv[4] = tmp/l1 tmp/l2 tmp/*4 tmp/l3 -./glob.tests: line 67: no match: tmp/*4 +./glob.tests: line 69: no match: tmp/*4 argv[1] = argv[1] = <*> argv[1] = diff --git a/tests/glob.tests b/tests/glob.tests index bdb2b774..db9d02b3 100644 --- a/tests/glob.tests +++ b/tests/glob.tests @@ -20,18 +20,20 @@ expect() : # if needed, change me to echo expect "$@" } +. ./test-aux-functions + # First, a test that bash-2.01.1 fails -${THIS_SH} ./glob1.sub -${THIS_SH} ./glob2.sub -${THIS_SH} ./glob3.sub -${THIS_SH} ./glob4.sub -${THIS_SH} ./glob5.sub -${THIS_SH} ./glob6.sub -${THIS_SH} ./glob7.sub -${THIS_SH} ./glob8.sub -${THIS_SH} ./glob9.sub -${THIS_SH} ./glob10.sub -${THIS_SH} ./glob11.sub +test_runsub ./glob1.sub +test_runsub ./glob2.sub +test_runsub ./glob3.sub +test_runsub ./glob4.sub +test_runsub ./glob5.sub +test_runsub ./glob6.sub +test_runsub ./glob7.sub +test_runsub ./glob8.sub +test_runsub ./glob9.sub +test_runsub ./glob10.sub +test_runsub ./glob11.sub MYDIR=$PWD # save where we are @@ -64,7 +66,7 @@ mkdir tmp touch tmp/l1 tmp/l2 tmp/l3 builtin echo tmp/l[12] tmp/*4 tmp/*3 shopt -s failglob -builtin echo tmp/l[12] tmp/*4 tmp/*3 +( builtin echo tmp/l[12] tmp/*4 tmp/*3 ) 2>&1 rm -r tmp shopt -u failglob diff --git a/tests/globstar.right b/tests/globstar.right index c8211bc8..78539a75 100644 --- a/tests/globstar.right +++ b/tests/globstar.right @@ -150,9 +150,11 @@ getenv.o input_avail.o itos.o alias.o builtins builtins/history.o builtins/jobs.o builtins/kill.o builtins/let.o builtins/mapfile.o lib lib/glob lib/glob/glob.o lib/glob/smatch.o lib/glob/strmatch.o lib/readline lib/readline/bind.o lib/readline/callback.o lib/readline/compat.o lib/readline/complete.o lib/readline/display.o lib/sh lib/sh/casemod.o lib/sh/clktck.o lib/sh/clock.o lib/sh/eaccess.o lib/sh/fdprintf.o lib/sh/fmtullong.o lib/sh/fmtulong.o lib/sh/fmtumax.o lib/sh/fpurge.o lib/sh/getenv.o lib/sh/input_avail.o lib/sh/itos.o pcomplib.o print_cmd.o redir.o shell.o sig.o stringlib.o subst.o syntax.o test.o trap.o unwind_prot.o variables.o version.o xmalloc.o y.tab.o + globstar1.sub bar/foo foo bar/foo/ foo/ bar/foo/e bar/foo/f foo/a foo/b + globstar2.sub @@ -582,6 +584,7 @@ bar/foo/e bar/foo/f foo/a foo/b + globstar3.sub a a/aa a/ab b b/bb b/bc c a/ b/ c/ a/ab b b/bb diff --git a/tests/globstar.tests b/tests/globstar.tests index 33714b4f..ce4157a8 100644 --- a/tests/globstar.tests +++ b/tests/globstar.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# : ${TMPDIR:=/var/tmp} dir=$PWD @@ -51,6 +53,6 @@ echo ** cd $dir rm -rf $GDIR -${THIS_SH} ./globstar1.sub -${THIS_SH} ./globstar2.sub -${THIS_SH} ./globstar3.sub +test_runsub ./globstar1.sub +test_runsub ./globstar2.sub +test_runsub ./globstar3.sub diff --git a/tests/heredoc.right b/tests/heredoc.right index 214ef520..5d751cc6 100644 --- a/tests/heredoc.right +++ b/tests/heredoc.right @@ -51,6 +51,7 @@ ENDOFINPUT aa=1 } + heredoc1.sub foo is a function foo () { @@ -70,7 +71,9 @@ qux bar qux + heredoc2.sub abc def geh + heredoc3.sub ./heredoc3.sub: line 20: warning: here-document at line 18 delimited by end-of-file (wanted `EOF') = here is the text = ./heredoc3.sub: line 26: warning: here-document at line 24 delimited by end-of-file (wanted `EOF') @@ -96,6 +99,7 @@ hello end hello\END ./heredoc3.sub: line 98: warning: here-document at line 96 delimited by end-of-file (wanted `EOF') ./heredoc3.sub: line 99: syntax error: unexpected end of file from `(' command on line 96 + heredoc4.sub heredoc1 EOF Ok:0 @@ -104,6 +108,8 @@ argv[2] = argv[1] = argv[2] = argv[3] = + heredoc5.sub + heredoc6.sub 1: OK 2: OK 3: OK @@ -124,6 +130,7 @@ argv[3] = 5: ${x#$pat} 6: ${y#$'not'} 7: ${y#'not'} + heredoc7.sub ./heredoc7.sub: line 17: warning: command substitution: 1 unterminated here-document foo bar ./heredoc7.sub: line 21: after: command not found @@ -131,6 +138,8 @@ foo bar ./heredoc7.sub: line 26: foobar: command not found ./heredoc7.sub: line 27: EOF: command not found grep: *.c: No such file or directory + heredoc8.sub + heredoc9.sub foo () { echo begin; @@ -153,6 +162,7 @@ HERE echo 3 4; done } + heredoc10.sub hello world hello @@ -162,7 +172,7 @@ here-doc line 2 here-document here-document comsub here-string -./heredoc.tests: line 184: warning: here-document at line 181 delimited by end-of-file (wanted `') +./heredoc.tests: line 186: warning: here-document at line 183 delimited by end-of-file (wanted `') hi there '' diff --git a/tests/heredoc.tests b/tests/heredoc.tests index d6431b8a..8c1bfc92 100644 --- a/tests/heredoc.tests +++ b/tests/heredoc.tests @@ -148,28 +148,30 @@ type fff export -f fff ${THIS_SH} -c 'type fff' -${THIS_SH} ./heredoc1.sub +. ./test-aux-functions + +test_runsub ./heredoc1.sub # test heredocs in command substitutions -${THIS_SH} ./heredoc2.sub -${THIS_SH} ./heredoc3.sub -${THIS_SH} ./heredoc4.sub +test_runsub ./heredoc2.sub +test_runsub ./heredoc3.sub +test_runsub ./heredoc4.sub # heredoc tests that use different size documents to test pipe implementation -${THIS_SH} ./heredoc5.sub +test_runsub ./heredoc5.sub # test $'...' and $"..." quoted strings in here-documents -${THIS_SH} ./heredoc6.sub +test_runsub ./heredoc6.sub # interaction between here-documents and command substitutions -${THIS_SH} ./heredoc7.sub -${THIS_SH} ./heredoc8.sub +test_runsub ./heredoc7.sub +test_runsub ./heredoc8.sub # various tests for printing here-documents in function bodies -${THIS_SH} ./heredoc9.sub +test_runsub ./heredoc9.sub # test various combinations of here-documents and aliases -${THIS_SH} ./heredoc10.sub +test_runsub ./heredoc10.sub echo $( cat <<< "comsub here-string" diff --git a/tests/herestr.right b/tests/herestr.right index 4ac2cc65..e7810222 100644 --- a/tests/herestr.right +++ b/tests/herestr.right @@ -32,6 +32,7 @@ echo $(echo hi) echo ho echo off to work we go declare -a uu=([0]="" [1]="kghfjk" [2]="jkfzuk" [3]=$'i\n') + herestr1.sub foo bar foo bar qux:::::bax diff --git a/tests/herestr.tests b/tests/herestr.tests index c97fa4f2..a1f85136 100644 --- a/tests/herestr.tests +++ b/tests/herestr.tests @@ -77,4 +77,5 @@ cat <<< "echo $(echo off to work we go)" IFS="/" read -r -d $'\000' -a uu <<< /kghfjk/jkfzuk/i declare -p uu +printf '\therestr1.sub\n' ${THIS_SH} ./herestr1.sub diff --git a/tests/histexp.right b/tests/histexp.right index cc8cb04d..1c30fc87 100644 --- a/tests/histexp.right +++ b/tests/histexp.right @@ -1,5 +1,5 @@ echo $BASH_VERSION -./histexp.tests: line 37: history: !!:z: history expansion failed +./histexp.tests: line 39: history: !!:z: history expansion failed 1 for i in one two three; do echo $i; done 2 /bin/sh -c 'echo this is $0' 3 ls @@ -138,6 +138,7 @@ echo four ; echo two 3 echo $((1+2)) 3 + histexp1.sub ! ! ! @@ -155,6 +156,7 @@ echo $((1+2)) 2 hi 0 ! ! + histexp2.sub a b c @@ -162,6 +164,7 @@ echo "#!/bin/bash" set -o posix #!/bin/bash set -o posix !! !! + histexp3.sub a echo $(echo echo a) echo a @@ -197,6 +200,7 @@ echo i echo i j echo `echo j` echo j j echo j + histexp4.sub a cat < <(echo echo a) echo a @@ -210,6 +214,7 @@ d e ! ! ./histexp4.sub: line 33: !': event not found + histexp5.sub /tmp/Step1 echo /$(echo tmp)/Step1 /tmp/Step1 @@ -230,6 +235,7 @@ echo +(/one|/two|/three)/Step1 *(/tmp|/dev|/usr)/Step1 echo *(/tmp|/dev|/usr)/Step1 *(/tmp|/dev|/usr)/Step1 + histexp6.sub one echo echo one echo one @@ -247,6 +253,7 @@ echo two 1 echo two 2 for f in a b c; do echo echo two; done 3 history + histexp7.sub a echo !! --between-- diff --git a/tests/histexp.tests b/tests/histexp.tests index 18a02816..2683cd4f 100644 --- a/tests/histexp.tests +++ b/tests/histexp.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# LC_ALL=C LANG=C trap 'rm $TMPDIR/newhistory' 0 @@ -153,10 +155,10 @@ echo !$ ; echo !:2:p echo $((1+2)) echo !!:1 -${THIS_SH} ./histexp1.sub -${THIS_SH} ./histexp2.sub -${THIS_SH} ./histexp3.sub -${THIS_SH} ./histexp4.sub -${THIS_SH} ./histexp5.sub -${THIS_SH} ./histexp6.sub -${THIS_SH} ./histexp7.sub +test_runsub ./histexp1.sub +test_runsub ./histexp2.sub +test_runsub ./histexp3.sub +test_runsub ./histexp4.sub +test_runsub ./histexp5.sub +test_runsub ./histexp6.sub +test_runsub ./histexp7.sub diff --git a/tests/history.right b/tests/history.right index 5e1ab36b..7c12f3e1 100644 --- a/tests/history.right +++ b/tests/history.right @@ -1,7 +1,7 @@ -./history.tests: line 17: history: -x: invalid option +./history.tests: line 19: history: -x: invalid option history: usage: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...] -./history.tests: line 19: history: cannot use more than one of -anrw -./history.tests: line 22: fc: -v: invalid option +./history.tests: line 21: history: cannot use more than one of -anrw +./history.tests: line 24: fc: -v: invalid option fc: usage: fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command] 1 for i in one two three; do echo $i; done 2 /bin/sh -c 'echo this is $0' @@ -97,7 +97,7 @@ line 2 for history 6 HISTFILE=$TMPDIR/newhistory 7 echo displaying \$HISTFILE after history -a 8 cat $HISTFILE -./history.tests: line 91: fc: no command found +./history.tests: line 93: fc: no command found 15 echo line 2 for history 16 unset HISTSIZE 17 unset HISTFILE @@ -107,7 +107,7 @@ echo xx xb xc xx xb xc echo 44 48 4c 44 48 4c -./history.tests: line 106: fc: no command found +./history.tests: line 108: fc: no command found aa bb cc @@ -121,6 +121,7 @@ echo cc echo cc cc 1 + history1.sub one two three @@ -142,10 +143,12 @@ two three (exit 42) 42 + history2.sub 5.3 echo ${BASH_VERSION%\.*} 5.3 echo ${BASH_VERSION%\.*} + history3.sub a b c @@ -182,6 +185,7 @@ i ./history3.sub: line 48: history: @42: invalid number ./history3.sub: line 49: history: @42: numeric argument required + history4.sub 0 1 @@ -231,6 +235,7 @@ mid right) A B + history5.sub a b ./history5.sub: line 24: fc: history specification out of range @@ -284,6 +289,7 @@ e 6 echo a 7 echo d 8 echo e + history6.sub 1 2 3 @@ -317,6 +323,7 @@ e 7 echo 9 8 echo 10 5 echo 10 + history7.sub $ 1 $ 2 $ 3 @@ -361,6 +368,7 @@ $ 1 $ 2 $ exit 0 + history8.sub a b c @@ -372,6 +380,7 @@ d 5 history ./history8.sub: line 15: history: 72: history position out of range ./history8.sub: line 16: history: -72: history position out of range + history9.sub 1 echo below zero 2 cat <. # +. ./test-aux-functions +# trap 'rm $TMPDIR/newhistory' 0 # bad options @@ -124,14 +126,14 @@ set +o history shopt -q -o history echo $? -${THIS_SH} ./history1.sub +test_runsub ./history1.sub rm -f $TMPDIR/foohist-* -${THIS_SH} ./history2.sub -${THIS_SH} ./history3.sub -${THIS_SH} ./history4.sub -${THIS_SH} ./history5.sub -${THIS_SH} ./history6.sub -${THIS_SH} ./history7.sub -${THIS_SH} ./history8.sub -${THIS_SH} ./history9.sub +test_runsub ./history2.sub +test_runsub ./history3.sub +test_runsub ./history4.sub +test_runsub ./history5.sub +test_runsub ./history6.sub +test_runsub ./history7.sub +test_runsub ./history8.sub +test_runsub ./history9.sub diff --git a/tests/ifs.right b/tests/ifs.right index 465efcf0..36431149 100644 --- a/tests/ifs.right +++ b/tests/ifs.right @@ -8,5 +8,6 @@ a:b:c:d:e a:b:c:d:e a b c d e a b c d e + ifs1.sub argv[1] = argv[1] = <*> diff --git a/tests/ifs.tests b/tests/ifs.tests index 27f27dd6..90f0de7b 100644 --- a/tests/ifs.tests +++ b/tests/ifs.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# OIFS="$IFS" IFS=":$IFS" eval foo="a:b:c" @@ -73,4 +75,4 @@ echo $x IFS="$DEFIFS" -${THIS_SH} ./ifs1.sub +test_runsub ./ifs1.sub diff --git a/tests/intl.right b/tests/intl.right index 7e25d29f..4943cb31 100644 --- a/tests/intl.right +++ b/tests/intl.right @@ -8,20 +8,25 @@ ok 2 aéb 0000000 141 303 251 142 0000004 + intl1.sub -абвгдежзиклмноп - 16 -абвгдежзиклмноп- 15 -абвгд- 5 + intl2.sub 1,0000 1.0000 1.0000 1.0000 1.0000 1,0000 + intl3.sub 1 bytematch 0000000 254 012 0000002 + unicode1.sub Passed all 1770 Unicode tests + unicode2.sub 0000000 303 277 012 0000003 0000000 303 277 012 @@ -50,11 +55,13 @@ Passed all 1770 Unicode tests 0000003 0000000 101 040 302 243 040 305 222 012 0000010 + unicode3.sub ./unicode3.sub: line 5: $'5\247@3\231+\306S8\237\242\352\263': command not found ./unicode3.sub: line 7: cd: $'5\247@3\231+\306S8\237\242\352\263': No such file or directory $'5\247@3\231+\306S8\237\242\352\263' + : $'5\247@3\231+\306S8\237\242\352\263' + set +x + intl4.sub ಇಳಿಕೆಗಳು ಇಳ ಇ diff --git a/tests/intl.tests b/tests/intl.tests index 2a4b26e0..5d86ec5a 100644 --- a/tests/intl.tests +++ b/tests/intl.tests @@ -54,17 +54,17 @@ printf '%s\n' "$*" printf '%s' "$*" | od -b | _intl_normalize_spaces # display differences make this problematic -${THIS_SH} ./intl1.sub +test_runsub ./intl1.sub # this tests both international handling in printf and temporary environments -${THIS_SH} ./intl2.sub +test_runsub ./intl2.sub # test splitting on characters instead of bytes -${THIS_SH} ./intl3.sub +test_runsub ./intl3.sub -${THIS_SH} ./unicode1.sub # 2>/dev/null -${THIS_SH} ./unicode2.sub +test_runsub ./unicode1.sub # 2>/dev/null +test_runsub ./unicode2.sub -${THIS_SH} ./unicode3.sub 2>&1 +test_runsub ./unicode3.sub 2>&1 -${THIS_SH} ./intl4.sub +test_runsub ./intl4.sub diff --git a/tests/invocation.right b/tests/invocation.right index 304fc91d..39e152b1 100644 --- a/tests/invocation.right +++ b/tests/invocation.right @@ -71,11 +71,13 @@ Shell options: -abefhkmnptuvxBCEHPT or -o option this-bash this-bash $- for -c includes c + invocation1.sub bash: line 0: badopt: invalid shell option name checkwinsize:cmdhist:complete_fullquote:extquote:force_fignore:globasciiranges:globskipdots:hostcomplete:interactive_comments:patsub_replacement:progcomp:promptvars:sourcepath checkhash:checkwinsize:cmdhist:complete_fullquote:extquote:force_fignore:globasciiranges:globskipdots:hostcomplete:interactive_comments:patsub_replacement:progcomp:promptvars:sourcepath cmdhist:complete_fullquote:extquote:force_fignore:globasciiranges:globskipdots:hostcomplete:interactive_comments:patsub_replacement:progcomp:promptvars:sourcepath ./invocation1.sub: line 40: BASHOPTS: readonly variable + invocation2.sub braceexpand:hashall:interactive-comments braceexpand:hashall:interactive-comments hashall:interactive-comments @@ -83,6 +85,7 @@ hashall:interactive-comments braceexpand:hashall:interactive-comments:noglob braceexpand:hashall:interactive-comments:noglob ./invocation2.sub: line 50: SHELLOPTS: readonly variable + invocation3.sub for i in 1 2 3; do select var in a b c; diff --git a/tests/invocation.tests b/tests/invocation.tests index c629c297..17128cdd 100644 --- a/tests/invocation.tests +++ b/tests/invocation.tests @@ -11,6 +11,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions : ${THIS_SH:=./bash} @@ -34,12 +35,12 @@ unset BASH_ARGV0 { ${THIS_SH} -c 'echo $-' bash | grep c >/dev/null; } && echo '$- for -c includes c' # BASHOPTS -${THIS_SH} ./invocation1.sub +test_runsub ./invocation1.sub # SHELLOPTS -${THIS_SH} ./invocation2.sub +test_runsub ./invocation2.sub # rudimentary pretty-print tests -${THIS_SH} ./invocation3.sub +test_runsub ./invocation3.sub : ${TMPDIR:=/tmp} TDIR=$TMPDIR/invocation-$$ diff --git a/tests/iquote.right b/tests/iquote.right index 9476128c..bb7c9cfa 100644 --- a/tests/iquote.right +++ b/tests/iquote.right @@ -59,6 +59,7 @@ argv[1] = argv[1] = argv[1] = argv[1] = + iquote1.sub argv[1] = argv[1] = argv[1] = diff --git a/tests/iquote.tests b/tests/iquote.tests index 8411c8ab..cdbca4a5 100644 --- a/tests/iquote.tests +++ b/tests/iquote.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# # bug in bash up to and including bash-3.0 (including patches) # # problem is conflict between CTLNUL used internally to denote quoted null @@ -155,4 +157,4 @@ recho ccc""ddd recho "eeefff" recho ggg"$(echo $'\177')"hhh -${THIS_SH} ./iquote1.sub +test_runsub ./iquote1.sub diff --git a/tests/jobs.right b/tests/jobs.right index 442b8260..e35aae31 100644 --- a/tests/jobs.right +++ b/tests/jobs.right @@ -1,5 +1,8 @@ + jobs1.sub + jobs2.sub ./jobs2.sub: line 9: fg: job 1 started without job control fg: 1 + jobs3.sub Waiting for job 0 job 0 returns 0 Waiting for job 1 @@ -16,6 +19,7 @@ Waiting for job 6 job 6 returns 0 Waiting for job 7 job 7 returns 0 + jobs4.sub [1] Running sleep 2 & [2] Running sleep 2 & [3] Running sleep 2 & @@ -24,6 +28,7 @@ job 7 returns 0 4 0 i killed it + jobs5.sub 12 [1]- Running sleep 20 & [3]+ Running sleep 20 & @@ -35,18 +40,22 @@ i killed it ./jobs5.sub: line 71: declare: wpid: not found ./jobs5.sub: line 74: wait: `invalid-varname': not a valid identifier ./jobs5.sub: line 76: wait: WV: cannot unset: readonly variable + jobs6.sub child1 exit status 0 + jobs7.sub [1]+ Running sleep 20 & ./jobs7.sub: line 5: fg: no current jobs [1]+ Running sleep 20 & + jobs8.sub + jobs9.sub got USR1 0 -./jobs.tests: line 45: wait: %1: no such job -./jobs.tests: line 50: fg: no job control +./jobs.tests: line 47: wait: %1: no such job +./jobs.tests: line 52: fg: no job control wait-for-pid wait-errors -./jobs.tests: line 70: wait: `1-1': not a pid or valid job spec -./jobs.tests: line 71: wait: `-4': not a pid or valid job spec +./jobs.tests: line 72: wait: `1-1': not a pid or valid job spec +./jobs.tests: line 73: wait: `-4': not a pid or valid job spec wait-for-background-pids async list wait-for-background-pids async list wait for child @@ -55,7 +64,7 @@ wait-when-no-children posix jobs output [1]+ Done sleep 1 wait-for-job -./jobs.tests: line 96: wait: %2: no such job +./jobs.tests: line 98: wait: %2: no such job 127 async list wait-for-job forked @@ -68,21 +77,21 @@ sleep 2 fg-bg 4 sleep 2 fg-bg 5 -./jobs.tests: line 123: fg: %2: no such job -./jobs.tests: line 124: bg: job 1 already in background +./jobs.tests: line 125: fg: %2: no such job +./jobs.tests: line 126: bg: job 1 already in background fg-bg 6 -./jobs.tests: line 131: fg: -s: invalid option +./jobs.tests: line 133: fg: -s: invalid option fg: usage: fg [job_spec] -./jobs.tests: line 132: bg: -s: invalid option +./jobs.tests: line 134: bg: -s: invalid option bg: usage: bg [job_spec ...] -./jobs.tests: line 137: disown: -s: invalid option +./jobs.tests: line 139: disown: -s: invalid option disown: usage: disown [-h] [-ar] [jobspec ... | pid ...] -./jobs.tests: line 141: disown: %1: no such job -./jobs.tests: line 144: disown: %2: no such job -./jobs.tests: line 147: disown: warning: @12: job specification requires leading `%' -./jobs.tests: line 147: disown: @12: no such job +./jobs.tests: line 143: disown: %1: no such job +./jobs.tests: line 146: disown: %2: no such job +./jobs.tests: line 149: disown: warning: @12: job specification requires leading `%' +./jobs.tests: line 149: disown: @12: no such job wait-for-non-child -./jobs.tests: line 150: wait: pid 1 is not a child of this shell +./jobs.tests: line 152: wait: pid 1 is not a child of this shell 127 3 -- 1 2 3 -- 1 - 2 - 3 [1] Running sleep 300 & @@ -92,8 +101,8 @@ running jobs: [1] Running sleep 300 & [2]- Running sleep 350 & [3]+ Running sleep 400 & -./jobs.tests: line 167: kill: %4: no such job -./jobs.tests: line 169: jobs: %4: no such job +./jobs.tests: line 169: kill: %4: no such job +./jobs.tests: line 171: jobs: %4: no such job current job: [3]+ Running sleep 400 & previous job: @@ -123,9 +132,9 @@ done after KILL -STOP, foregrounding %1 sleep 4 done -./jobs.tests: line 229: jobs: -q: invalid option +./jobs.tests: line 231: jobs: -q: invalid option jobs: usage: jobs [-lnprs] [jobspec ...] or jobs -x command [args] -./jobs.tests: line 231: suspend: -z: invalid option +./jobs.tests: line 233: suspend: -z: invalid option suspend: usage: suspend [-f] -./jobs.tests: line 232: suspend: cannot suspend: no job control -./jobs.tests: line 233: suspend: cannot suspend: no job control +./jobs.tests: line 234: suspend: cannot suspend: no job control +./jobs.tests: line 235: suspend: cannot suspend: no job control diff --git a/tests/jobs.tests b/tests/jobs.tests index 4fa19b7c..1b98ba0c 100644 --- a/tests/jobs.tests +++ b/tests/jobs.tests @@ -11,32 +11,34 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# # test out %+, jobs -p, and $! agreement in a subshell first -${THIS_SH} ./jobs1.sub +test_runsub ./jobs1.sub # test out fg/bg failure in a subshell -${THIS_SH} ./jobs2.sub +test_runsub ./jobs2.sub # test out behavior of waiting for background pids -- bug in versions # before 2.03 -${THIS_SH} ./jobs3.sub +test_runsub ./jobs3.sub # test out behavior of using job control notation when job control is not # active -${THIS_SH} ./jobs4.sub +test_runsub ./jobs4.sub # test out wait -n framework -${THIS_SH} ./jobs5.sub +test_runsub ./jobs5.sub # test out wait -f framework -${THIS_SH} ./jobs6.sub +test_runsub ./jobs6.sub -${THIS_SH} ./jobs7.sub +test_runsub ./jobs7.sub # more disown -h tests -${THIS_SH} ./jobs8.sub +test_runsub ./jobs8.sub # wait interrupted by signal for which a trap has been set -${THIS_SH} ./jobs9.sub +test_runsub ./jobs9.sub jobs echo $? diff --git a/tests/lastpipe.right b/tests/lastpipe.right index d311d6f8..6c2b5fef 100644 --- a/tests/lastpipe.right +++ b/tests/lastpipe.right @@ -8,7 +8,9 @@ last = c 1 -- 0 0 1 1 -- 0 1 0 1 42 + lastpipe1.sub lastpipe1.sub returns 14 + lastpipe2.sub A1 A2 B1 @@ -19,5 +21,6 @@ A2 B1 B2 HI -- 42 -- 0 42 + lastpipe3.sub x=x x=x diff --git a/tests/lastpipe.tests b/tests/lastpipe.tests index 2fc5e8e6..e7239b38 100644 --- a/tests/lastpipe.tests +++ b/tests/lastpipe.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# binfalse() { $binfalse || return 1 # normalize return value @@ -70,8 +72,8 @@ binfalse | true | true | VAR=42 echo $? $VAR set +o pipefail -${THIS_SH} ./lastpipe1.sub +test_runsub ./lastpipe1.sub echo lastpipe1.sub returns $? -${THIS_SH} ./lastpipe2.sub -${THIS_SH} ./lastpipe3.sub +test_runsub ./lastpipe2.sub +test_runsub ./lastpipe3.sub diff --git a/tests/mapfile.right b/tests/mapfile.right index 4452232d..3685e9f7 100644 --- a/tests/mapfile.right +++ b/tests/mapfile.right @@ -152,6 +152,7 @@ a [28] aaa [29] aaa declare -a array=([0]="a" [1]="b" [2]="c" [3]=$'\n') + mapfile1.sub 1 2 3 4 5 foo 0 1 @@ -163,6 +164,7 @@ foo 3 4 foo 4 5 + mapfile2.sub 0 abc 1 def 2 ghi diff --git a/tests/mapfile.tests b/tests/mapfile.tests index c2ea7d24..a866a5f5 100644 --- a/tests/mapfile.tests +++ b/tests/mapfile.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# declare -a A mapfile A < mapfile.data for (( i = 0 ; i < ${#A[@]} ; i++ )); do @@ -58,5 +60,5 @@ mapfile -t -d $'\xff' array <<<"$s" declare -p array unset -v s array -${THIS_SH} ./mapfile1.sub -${THIS_SH} ./mapfile2.sub +test_runsub ./mapfile1.sub +test_runsub ./mapfile2.sub diff --git a/tests/nameref.right b/tests/nameref.right index ec424e0f..ef3ef710 100644 --- a/tests/nameref.right +++ b/tests/nameref.right @@ -27,20 +27,23 @@ changevar: expect argv[1] = expect argv[1] = -./nameref.tests: line 106: foo: readonly variable -./nameref.tests: line 107: foo: readonly variable +./nameref.tests: line 108: foo: readonly variable +./nameref.tests: line 109: foo: readonly variable one one -./nameref.tests: line 119: foo: readonly variable -./nameref.tests: line 116: foo: readonly variable +./nameref.tests: line 121: foo: readonly variable +./nameref.tests: line 118: foo: readonly variable one abxde abxde + nameref1.sub one bar + nameref2.sub ./nameref2.sub: line 5: foo: readonly variable + nameref3.sub expect argv[1] = expect @@ -57,6 +60,7 @@ two three unset four + nameref4.sub 0 expect a b @@ -97,6 +101,7 @@ X expect X errors = 0 + nameref5.sub 1 2 v1: 1 @@ -114,6 +119,7 @@ ref -> one, value: 1 ref -> two, value: 2 ref -> three, value: 3 final state: ref -> three, value: 3 + nameref6.sub ./nameref6.sub: line 15: typeset: x: nameref variable self references not allowed ./nameref6.sub: line 18: typeset: x[3]: reference variable cannot be an array ./nameref6.sub: line 25: typeset: x: reference variable cannot be an array @@ -123,8 +129,10 @@ y -- 0 2 -- 0 2 -- 0 y -- 0 + nameref7.sub bar unset + nameref8.sub ./nameref8.sub: line 16: typeset: warning: v: circular name reference ./nameref8.sub: line 16: warning: v: circular name reference ./nameref8.sub: line 18: warning: v: maximum nameref depth (8) exceeded @@ -143,10 +151,12 @@ local ./nameref8.sub: line 67: warning: x: circular name reference ./nameref8.sub: line 68: warning: x: circular name reference x = + nameref9.sub idx2 idX2 idx2 idX2 + nameref10.sub declare -n foo="x[\$zero]" 42 declare -a x=([0]="4") @@ -180,6 +190,7 @@ declare -i bar="8" 8 declare -n foo="bar" ./nameref10.sub: line 77: typeset: bar: not found + nameref11.sub ./nameref11.sub: line 14: declare: `/': invalid variable name for name reference ./nameref11.sub: line 15: declare: `/': invalid variable name for name reference ./nameref11.sub: line 16: `/': not a valid identifier @@ -210,33 +221,34 @@ x declare -a r=() ./nameref11.sub: line 33: declare: r: reference variable cannot be an array ./nameref11.sub: line 34: printf: `/': not a valid identifier -./nameref11.sub: line 36: `': not a valid identifier -./nameref11.sub: line 37: declare: `': not a valid identifier ./nameref11.sub: line 38: `': not a valid identifier -./nameref11.sub: line 39: printf: `': not a valid identifier -./nameref11.sub: line 40: declare: `': invalid variable name for name reference +./nameref11.sub: line 39: declare: `': not a valid identifier +./nameref11.sub: line 40: `': not a valid identifier +./nameref11.sub: line 41: printf: `': not a valid identifier +./nameref11.sub: line 42: declare: `': invalid variable name for name reference declare -r ROVAR="42" -./nameref11.sub: line 45: ROVAR: readonly variable -./nameref11.sub: line 45: ROVAR: cannot unset: readonly variable +./nameref11.sub: line 47: ROVAR: readonly variable +./nameref11.sub: line 47: ROVAR: cannot unset: readonly variable declare -r ROVAR="42" ./nameref11.sub -./nameref11.sub: line 47: `@': not a valid identifier +./nameref11.sub: line 49: `@': not a valid identifier ./nameref11.sub declare -n ref="x" -./nameref11.sub: line 52: RO: readonly variable +./nameref11.sub: line 54: RO: readonly variable declare -r RO_PID -./nameref11.sub: line 52: RO: cannot unset: readonly variable +./nameref11.sub: line 54: RO: cannot unset: readonly variable declare -r RO="x" -./nameref11.sub: line 52: declare: RO_PID: not found -./nameref11.sub: line 54: RO2: readonly variable +./nameref11.sub: line 54: declare: RO_PID: not found +./nameref11.sub: line 56: RO2: readonly variable declare -r RO2="a" 2 -./nameref11.sub: line 65: typeset: `2': invalid variable name for name reference +./nameref11.sub: line 67: typeset: `2': invalid variable name for name reference 2 -./nameref11.sub: line 70: typeset: `2': invalid variable name for name reference +./nameref11.sub: line 72: typeset: `2': invalid variable name for name reference 2 -./nameref11.sub: line 75: foo[2]: invalid indirect expansion -./nameref11.sub: line 76: bar: invalid indirect expansion +./nameref11.sub: line 77: foo[2]: invalid indirect expansion +./nameref11.sub: line 78: bar: invalid indirect expansion + nameref12.sub ./nameref12.sub: line 19: declare: `/': invalid variable name for name reference ./nameref12.sub: line 22: declare: `%': invalid variable name for name reference ./nameref12.sub: line 26: `^': not a valid identifier @@ -262,6 +274,7 @@ declare -n ref declare -- ref="global" declare -a var=([0]="foo2") ./nameref12.sub: line 113: declare: global: not found + nameref13.sub declare -- a declare -n r="a" declare -- a @@ -278,6 +291,7 @@ declare -n r declare -n foo ./nameref13.sub: line 110: typeset: `12345': invalid variable name for name reference declare -n foo + nameref14.sub declare -nx ref="var" var var @@ -300,6 +314,7 @@ after declare -n ref="var" ./nameref14.sub: line 45: typeset: var: not found declare -n ref="var" + nameref15.sub ./nameref15.sub: line 14: local: warning: a: circular name reference ./nameref15.sub: line 14: warning: a: circular name reference ./nameref15.sub: line 14: `a[0]': not a valid identifier @@ -356,6 +371,7 @@ declare -a v=([0]="0") declare -a xref=([1]="one") ./nameref15.sub: line 126: warning: xref: removing nameref attribute declare -a xref=([1]="one") + nameref16.sub declare -n r1="y" declare -n r2="x" ./nameref16.sub: line 25: typeset: x: not found @@ -372,6 +388,7 @@ declare -n r1="y" declare -n r2="x" declare -- x="one" declare -- y="two" + nameref17.sub ./nameref17.sub: line 21: declare: bar: not found ./nameref17.sub: line 22: unset: foo0: cannot unset: readonly variable declare -nr foo0="bar" @@ -409,6 +426,7 @@ declare -nr foo5 declare -r foo5 declare -nr foo5 declare -r foo5 + nameref18.sub ./nameref18.sub: line 15: mapfile: `XXX[0]': not a valid identifier ./nameref18.sub: line 16: declare: XXX[0]: not found ./nameref18.sub: line 22: `XXX[0]': not a valid identifier @@ -450,6 +468,7 @@ argv[2] = <2> argv[3] = <31> argv[4] = <2> argv[5] = <3> + nameref19.sub declare -n foo="bar" declare -- foo="bar" ./nameref19.sub: line 22: declare: bar: not found @@ -468,6 +487,7 @@ declare -- foo="bar" declare -- bar 8 declare -n ivar="foo" + nameref20.sub declare -a v=([0]="Y") r: v: @@ -497,6 +517,7 @@ declare -- ref="Y" declare -- ref="Y" ./nameref20.sub: line 74: declare: var: not found declare -- ref="Y" + nameref21.sub declare -n ref="var" declare -A var=([2]="" ) declare -n ref="var" @@ -511,6 +532,7 @@ declare -n ref="var" declare -ai var=([1]="0") declare -n ref="var" declare -- var="1" + nameref22.sub a string with spaces many spaces declare -n foo="bar[0]" @@ -532,6 +554,7 @@ declare -a array declare -ai array=([0]="one") declare -a array=([0]="zero") declare -a array=([0]="one" [1]="two" [2]="three") + nameref23.sub declare -ai a=([0]="5") declare -ai a=([0]="6") declare -ai a=([0]="42") @@ -566,6 +589,7 @@ declare -ai a=([0]="0" [1]="16") 12 16 declare -ai a=([0]="0" [1]="16") + nameref24.sub ./nameref24.sub: line 24: declare: `': not a valid identifier ./nameref24.sub: line 25: declare: `a&b': invalid variable name for name reference 3 @@ -577,6 +601,7 @@ declare -ai a=([0]="0" [1]="16") 3 3 5 + nameref25.sub bash: line 1: a[k]: unbound variable ok 1 bash: line 1: r0: unbound variable diff --git a/tests/nameref.tests b/tests/nameref.tests index 3a6c5d98..ecb65633 100644 --- a/tests/nameref.tests +++ b/tests/nameref.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions + # basic nameref tests bar=one flow=two @@ -129,5 +131,5 @@ echo ${!x//c/x} echo ${v//c/x} for testfile in ./nameref[0-9].sub ./nameref[1-9][0-9].sub ; do - ${THIS_SH} "$testfile" + test_runsub "$testfile" done diff --git a/tests/nameref11.sub b/tests/nameref11.sub index ea14c0db..19de4ee6 100644 --- a/tests/nameref11.sub +++ b/tests/nameref11.sub @@ -33,6 +33,8 @@ declare -n r; mapfile r < /dev/null ; declare -p r; unset r ; unset -n r mapfile r < /dev/null; declare -n r ; unset r ; unset -n r declare -n r; printf -v r / ; unset -n r +declare -n r ; declare -u r r ; unset -n r + declare -n r; r="" ; unset -n r declare -n r="" ; unset -n r declare -n r; : ${r=} ; unset -n r diff --git a/tests/new-exp.right b/tests/new-exp.right index d412e8ac..ac720ac3 100644 --- a/tests/new-exp.right +++ b/tests/new-exp.right @@ -3,7 +3,7 @@ argv[1] = argv[1] = argv[1] = argv[1] = -./new-exp.tests: line 41: HOME: }: arithmetic syntax error: operand expected (error token is "}") +./new-exp.tests: line 43: HOME: }: arithmetic syntax error: operand expected (error token is "}") unset argv[1] = argv[1] = @@ -59,7 +59,7 @@ argv[1] = <4> argv[1] = argv[1] = argv[1] = -./new-exp.tests: line 189: bad-var: invalid variable name +./new-exp.tests: line 191: bad-var: invalid variable name argv[1] = argv[2] = argv[3] = @@ -67,8 +67,8 @@ argv[4] = argv[1] = argv[2] = argv[3] = -./new-exp.tests: line 202: ABX: unbound variable -./new-exp.tests: line 206: $6: cannot assign in this way +./new-exp.tests: line 204: ABX: unbound variable +./new-exp.tests: line 208: $6: cannot assign in this way argv[1] = argv[1] = argv[1] = @@ -168,16 +168,8 @@ has multiple lines. This-string-has-multiple-lines. -this is a test of proc subst -this is test 2 -a -./new-exp2.sub: line 55: /tmp/redir-notthere: No such file or directory -1 - -./new-exp2.sub: line 62: 1111111111111111111111: command not found - argv[1] = <6> -./new-exp.tests: line 307: ${#:}: bad substitution +./new-exp.tests: line 300: ${#:}: bad substitution argv[1] = <'> argv[1] = <"> argv[1] = <"hello"> @@ -412,60 +404,18 @@ argv[6] = argv[7] = argv[8] = argv[9] = -./new-exp.tests: line 525: $9: unbound variable -./new-exp.tests: line 526: 9: unbound variable -./new-exp.tests: line 527: UNSET: unbound variable -./new-exp.tests: line 528: UNSET: unbound variable -./new-exp.tests: line 529: UNSET: unbound variable -./new-exp.tests: line 530: UNSET: unbound variable -./new-exp.tests: line 531: UNSET: unbound variable +./new-exp.tests: line 518: $9: unbound variable +./new-exp.tests: line 519: 9: unbound variable +./new-exp.tests: line 520: UNSET: unbound variable +./new-exp.tests: line 521: UNSET: unbound variable +./new-exp.tests: line 522: UNSET: unbound variable +./new-exp.tests: line 523: UNSET: unbound variable +./new-exp.tests: line 524: UNSET: unbound variable argv[1] = <5> argv[1] = <#> argv[1] = <#> argv[1] = <> -argv[1] = <_QUANTITY> -argv[2] = <_QUART> -argv[3] = <_QUEST> -argv[4] = <_QUILL> -argv[5] = <_QUOTA> -argv[6] = <_QUOTE> -argv[1] = <_QUANTITY> -argv[2] = <_QUART> -argv[3] = <_QUEST> -argv[4] = <_QUILL> -argv[5] = <_QUOTA> -argv[6] = <_QUOTE> -argv[1] = <_QUANTITY> -argv[2] = <_QUART> -argv[3] = <_QUEST> -argv[4] = <_QUILL> -argv[5] = <_QUOTA> -argv[6] = <_QUOTE> -argv[1] = <_QUANTITY-_QUART-_QUEST-_QUILL-_QUOTA-_QUOTE> -argv[1] = <_QUANTITY> -argv[2] = <_QUART> -argv[3] = <_QUEST> -argv[4] = <_QUILL> -argv[5] = <_QUOTA> -argv[6] = <_QUOTE> -argv[1] = <_QUANTITY> -argv[2] = <_QUART> -argv[3] = <_QUEST> -argv[4] = <_QUILL> -argv[5] = <_QUOTA> -argv[6] = <_QUOTE> -./new-exp3.sub: line 36: ${!_Q* }: bad substitution -./new-exp3.sub: line 41: ${!1*}: bad substitution -./new-exp3.sub: line 43: ${!@*}: bad substitution -Case01---3---A:B:C--- -Case02---1---A B C::--- -Case03---3---A:B:C--- -Case04---3---A:B:C--- -Case05---3---A:B:C--- -Case06---1---A B C::--- -Case07---3---A:B:C--- -Case08---3---A:B:C--- -./new-exp.tests: line 551: ${$(($#-1))}: bad substitution +./new-exp.tests: line 538: ${$(($#-1))}: bad substitution argv[1] = argv[2] = argv[3] = @@ -482,8 +432,8 @@ argv[1] = argv[1] = argv[2] = argv[1] = <> -./new-exp.tests: line 570: $(($# - 2)): substring expression < 0 -./new-exp.tests: line 572: -2: substring expression < 0 +./new-exp.tests: line 557: $(($# - 2)): substring expression < 0 +./new-exp.tests: line 559: -2: substring expression < 0 argv[1] = argv[2] = argv[3] = @@ -515,6 +465,78 @@ argv[1] = argv[1] = argv[1] = argv[1] = +h +h +--blah +--blah +lah +lah +abcde abcfg abchi +foode foofg foohi +argv[1] = +argv[1] = + +1/##2/%3 +1/##2/##3 +1##2/%3 +1/%%2/#3 +1/%%2/%%3 +1%%2/#3 + new-exp1.sub +this is a test of proc subst +this is test 2 +a + new-exp2.sub +./new-exp2.sub: line 55: /tmp/redir-notthere: No such file or directory +1 + +./new-exp2.sub: line 62: 1111111111111111111111: command not found + + new-exp3.sub +argv[1] = <_QUANTITY> +argv[2] = <_QUART> +argv[3] = <_QUEST> +argv[4] = <_QUILL> +argv[5] = <_QUOTA> +argv[6] = <_QUOTE> +argv[1] = <_QUANTITY> +argv[2] = <_QUART> +argv[3] = <_QUEST> +argv[4] = <_QUILL> +argv[5] = <_QUOTA> +argv[6] = <_QUOTE> +argv[1] = <_QUANTITY> +argv[2] = <_QUART> +argv[3] = <_QUEST> +argv[4] = <_QUILL> +argv[5] = <_QUOTA> +argv[6] = <_QUOTE> +argv[1] = <_QUANTITY-_QUART-_QUEST-_QUILL-_QUOTA-_QUOTE> +argv[1] = <_QUANTITY> +argv[2] = <_QUART> +argv[3] = <_QUEST> +argv[4] = <_QUILL> +argv[5] = <_QUOTA> +argv[6] = <_QUOTE> +argv[1] = <_QUANTITY> +argv[2] = <_QUART> +argv[3] = <_QUEST> +argv[4] = <_QUILL> +argv[5] = <_QUOTA> +argv[6] = <_QUOTE> +./new-exp3.sub: line 36: ${!_Q* }: bad substitution +./new-exp3.sub: line 41: ${!1*}: bad substitution +./new-exp3.sub: line 43: ${!@*}: bad substitution + new-exp4.sub +Case01---3---A:B:C--- +Case02---1---A B C::--- +Case03---3---A:B:C--- +Case04---3---A:B:C--- +Case05---3---A:B:C--- +Case06---1---A B C::--- +Case07---3---A:B:C--- +Case08---3---A:B:C--- + new-exp5.sub two one ne @@ -534,14 +556,7 @@ one 9 4, A B C D 2, C D -h -h ---blah ---blah -lah -lah -abcde abcfg abchi -foode foofg foohi + new-exp6.sub argv[1] = <> argv[1] = <+> argv[1] = <+^?> @@ -558,6 +573,7 @@ argv[1] = <12> argv[1] = <> argv[1] = <> argv[1] = + new-exp7.sub foo is a function foo () { @@ -573,6 +589,7 @@ bar () { echo < <(cat x1) } + new-exp8.sub start;ing0;ing1;ing2;ing3;ing4;ing5;ing6;ing7;ing8;ing9;ing10;ing11;ing12;ing13;ing14;ing15;ing16;ing17;ing18;ing19;ing20;ing21;ing22;ing23;ing24;ing25;ing26;ing27;ing28;ing29;ing30;ing31;ing32;ing33;ing34;ing35;ing36;ing37;ing38;ing39;ing40;ing41;ing42;ing43;ing44;ing45;ing46;ing47;ing48;ing49;ing50;ing51;ing52;ing53;ing54;ing55;ing56;ing57;ing58;ing59;ing60;ing61;ing62;ing63;ing64;ing65;ing66;ing67;ing68;ing69;ing70;ing71;ing72;ing73;ing74;ing75;ing76;ing77;ing78;ing79;ing80;ing81;ing82;ing83;ing84;ing85;ing86;ing87;ing88;ing89;ing90;ing91;ing92;ing93;ing94;ing95;ing96;ing97;ing98;ing99;ing100;ing101;ing102;ing103;ing104;ing105;ing106;ing107;ing108;ing109;ing110;ing111;ing112;ing113;ing114;ing115;ing116;ing117;ing118;ing119;ing120;ing121;ing122;ing123;ing124;ing125;ing126;ing127;ing128;ing129;ing130;ing131;ing132;ing133;ing134;ing135;ing136;ing137;ing138;ing139;ing140;ing141;ing142;ing143;ing144;ing145;ing146;ing147;ing148;ing149;ing150;ing151;ing152;ing153;ing154;ing155;ing156;ing157;ing158;ing159;ing160;ing161;ing162;ing163;ing164;ing165;ing166;ing167;ing168;ing169;ing170;ing171;ing172;ing173;ing174;ing175;ing176;ing177;ing178;ing179;ing180;ing181;ing182;ing183;ing184;ing185;ing186;ing187;ing188;ing189;ing190;ing191;ing192;ing193;ing194;ing195;ing196;ing197;ing198;ing199;ing200;ing201;ing202;ing203;ing204;ing205;ing206;ing207;ing208;ing209;ing210;ing211;ing212;ing213;ing214;ing215;ing216;ing217;ing218;ing219;ing220;ing221;ing222;ing223;ing224;ing225;ing226;ing227;ing228;ing229;ing230;ing231;ing232;ing233;ing234;ing235;ing236;ing237;ing238;ing239;ing240;ing241;ing242;ing243;ing244;ing245;ing246;ing247;ing248;ing249;ing250;ing251;ing252;ing253;ing254;ing255;ing256;ing257;ing258;ing259;ing260;ing261;ing262;ing263;ing264;ing265;ing266;ing267;ing268;ing269;ing270;ing271;ing272;ing273;ing274;ing275;ing276;ing277;ing278;ing279;ing280;ing281;ing282;ing283;ing284;ing285;ing286;ing287;ing288;ing289;ing290;ing291;ing292;ing293;ing294;ing295;ing296;ing297;ing298;ing299;ing300;ing301;ing302;ing303;ing304;ing305;ing306;ing307;ing308;ing309;ing310;ing311;ing312;ing313;ing314;ing315;ing316;ing317;ing318;ing319;ing320;ing321;ing322;ing323;ing324;ing325;ing326;ing327;ing328;ing329;ing330;ing331;ing332;ing333;ing334;ing335;ing336;ing337;ing338;ing339;ing340;ing341;ing342;ing343;ing344;ing345;ing346;ing347;ing348;ing349;ing350;ing351;ing352;ing353;ing354;ing355;ing356;ing357;ing358;ing359;ing360;ing361;ing362;ing363;ing364;ing365;ing366;ing367;ing368;ing369;ing370;ing371;ing372;ing373;ing374;ing375;ing376;ing377;ing378;ing379;ing380;ing381;ing382;ing383;ing384;ing385;ing386;ing387;ing388;ing389;ing390;ing391;ing392;ing393;ing394;ing395;ing396;ing397;ing398;ing399;ing400;ing401;ing402;ing403;ing404;ing405;ing406;ing407;ing408;ing409;ing410;ing411;ing412;ing413;ing414;ing415;ing416;ing417;ing418;ing419;ing420;ing421;ing422;ing423;ing424;ing425;ing426;ing427;ing428;ing429;ing430;ing431;ing432;ing433;ing434;ing435;ing436;ing437;ing438;ing439;ing440;ing441;ing442;ing443;ing444;ing445;ing446;ing447;ing448;ing449;ing450;ing451;ing452;ing453;ing454;ing455;ing456;ing457;ing458;ing459;ing460;ing461;ing462;ing463;ing464;ing465;ing466;ing467;ing468;ing469;ing470;ing471;ing472;ing473;ing474;ing475;ing476;ing477;ing478;ing479;ing480;ing481;ing482;ing483;ing484;ing485;ing486;ing487;ing488;ing489;ing490;ing491;ing492;ing493;ing494;ing495;ing496;ing497;ing498;ing499;ing500;ing501;ing502;ing503;ing504;ing505;ing506;ing507;ing508;ing509;ing510;ing511;ing512;ing513;ing514;ing515;ing516;ing517;ing518;ing519;ing520;ing521;ing522;ing523;ing524;ing525;ing526;ing527;ing528;ing529;ing530;ing531;ing532;ing533;ing534;ing535;ing536;ing537;ing538;ing539;ing540;ing541;ing542;ing543;ing544;ing545;ing546;ing547;ing548;ing549;ing550;ing551;ing552;ing553;ing554;ing555;ing556;ing557;ing558;ing559;ing560;ing561;ing562;ing563;ing564;ing565;ing566;ing567;ing568;ing569;ing570;ing571;ing572;ing573;ing574;ing575;ing576;ing577;ing578;ing579;ing580;ing581;ing582;ing583;ing584;ing585;ing586;ing587;ing588;ing589;ing590;ing591;ing592;ing593;ing594;ing595;ing596;ing597;ing598;ing599;ing600;ing601;ing602;ing603;ing604;ing605;ing606;ing607;ing608;ing609;ing610;ing611;ing612;ing613;ing614;ing615;ing616;ing617;ing618;ing619;ing620;ing621;ing622;ing623;ing624;ing625;ing626;ing627;ing628;ing629;ing630;ing631;ing632;ing633;ing634;ing635;ing636;ing637;ing638;ing639;ing640;ing641;ing642;ing643;ing644;ing645;ing646;ing647;ing648;ing649;ing650;ing651;ing652;ing653;ing654;ing655;ing656;ing657;ing658;ing659;ing660;ing661;ing662;ing663;ing664;ing665;ing666;ing667;ing668;ing669;ing670;ing671;ing672;ing673;ing674;ing675;ing676;ing677;ing678;ing679;ing680;ing681;ing682;ing683;ing684;ing685;ing686;ing687;ing688;ing689;ing690;ing691;ing692;ing693;ing694;ing695;ing696;ing697;ing698;ing699;ing700;ing701;ing702;ing703;ing704;ing705;ing706;ing707;ing708;ing709;ing710;ing711;ing712;ing713;ing714;ing715;ing716;ing717;ing718;ing719;ing720;ing721;ing722;ing723;ing724;ing725;ing726;ing727;ing728;ing729;ing730;ing731;ing732;ing733;ing734;ing735;ing736;ing737;ing738;ing739;ing740;ing741;ing742;ing743;ing744;ing745;ing746;ing747;ing748;ing749;ing750;ing751;ing752;ing753;ing754;ing755;ing756;ing757;ing758;ing759;ing760;ing761;ing762;ing763;ing764;ing765;ing766;ing767;ing768;ing769;ing770;ing771;ing772;ing773;ing774;ing775;ing776;ing777;ing778;ing779;ing780;ing781;ing782;ing783;ing784;ing785;ing786;ing787;ing788;ing789;ing790;ing791;ing792;ing793;ing794;ing795;ing796;ing797;ing798;ing799;ing800;ing801;ing802;ing803;ing804;ing805;ing806;ing807;ing808;ing809;ing810;ing811;ing812;ing813;ing814;ing815;ing816;ing817;ing818;ing819;ing820;ing821;ing822;ing823;ing824;ing825;ing826;ing827;ing828;ing829;ing830;ing831;ing832;ing833;ing834;ing835;ing836;ing837;ing838;ing839;ing840;ing841;ing842;ing843;ing844;ing845;ing846;ing847;ing848;ing849;ing850;ing851;ing852;ing853;ing854;ing855;ing856;ing857;ing858;ing859;ing860;ing861;ing862;ing863;ing864;ing865;ing866;ing867;ing868;ing869;ing870;ing871;ing872;ing873;ing874;ing875;ing876;ing877;ing878;ing879;ing880;ing881;ing882;ing883;ing884;ing885;ing886;ing887;ing888;ing889;ing890;ing891;ing892;ing893;ing894;ing895;ing896;ing897;ing898;ing899;ing900;ing901;ing902;ing903;ing904;ing905;ing906;ing907;ing908;ing909;ing910;ing911;ing912;ing913;ing914;ing915;ing916;ing917;ing918;ing919;ing920;ing921;ing922;ing923;ing924;ing925;ing926;ing927;ing928;ing929;ing930;ing931;ing932;ing933;ing934;ing935;ing936;ing937;ing938;ing939;ing940;ing941;ing942;ing943;ing944;ing945;ing946;ing947;ing948;ing949;ing950;ing951;ing952;ing953;ing954;ing955;ing956;ing957;ing958;ing959;ing960;ing961;ing962;ing963;ing964;ing965;ing966;ing967;ing968;ing969;ing970;ing971;ing972;ing973;ing974;ing975;ing976;ing977;ing978;ing979;ing980;ing981;ing982;ing983;ing984;ing985;ing986;ing987;ing988;ing989;ing990;ing991;ing992;ing993;ing994;ing995;ing996;ing997;ing998;ing999 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -605,6 +622,7 @@ axd axxd axxd zzzz + new-exp9.sub a Value = 1 2 3 4 5 a Sub = 0 1 2 3 4 b Value = a b c d e @@ -613,6 +631,7 @@ c Value = 10 20 40 80 c Sub = 0 2 4 8 <1> <2> <3> <4> <5> <10> <20> <40> <80> + new-exp10.sub <> <> <> @@ -658,6 +677,7 @@ argv[1] = <^A^G^B[0:1]~\$ > argv[1] = argv[1] = <1^J/ bash$ > ./new-exp10.sub: line 153: ${V@}: bad substitution + new-exp11.sub abcxxxdef abcÃ¥def ḅć @@ -678,9 +698,11 @@ prependÃ¥ Ã¥ ḅć ḅć + new-exp12.sub HELLO;1 foo;2 foo; PASS;1 foo;2 foo; after: PASS + new-exp13.sub 'zzz' 'zzz' declare -rl VAR1 @@ -712,6 +734,7 @@ aaa bbb 'aaa' 'bbb' a bbb aaa bb + new-exp14.sub 'string' 'string' 'value with spaces' @@ -728,6 +751,7 @@ argv[5] = <2> argv[6] = argv[7] = <3> argv[8] = + new-exp15.sub declare -a foo=() ai declare -ai foo @@ -739,6 +763,7 @@ a a a a + new-exp16.sub /homes/chetdefg /homes/chetdefg ~defg @@ -798,13 +823,4 @@ two &two otwone &twone -argv[1] = -argv[1] = - -1/##2/%3 -1/##2/##3 -1##2/%3 -1/%%2/#3 -1/%%2/%%3 -1%%2/#3 ./new-exp.tests: line 1: ABXD: parameter unset diff --git a/tests/new-exp.tests b/tests/new-exp.tests index 43c22209..05959ac2 100644 --- a/tests/new-exp.tests +++ b/tests/new-exp.tests @@ -15,6 +15,8 @@ if (( $UID == 0 )); then echo "new-exp.tests: the test suite should not be run as root" >&2 fi +. ./test-aux-functions + # must do this because posix mode causes process substitution to be disabled # and flagged as a syntax error, which causes the shell to exit set +o posix @@ -292,15 +294,6 @@ echo "$BVAR" unset AVAR BVAR -# run process substitution tests in a subshell so that syntax errors -# caused by a shell not implementing process substitution (e.g., one -# built on a NeXT) will not cause the whole test to exit prematurely -${THIS_SH} ./new-exp1.sub - -# run the tests of $(' recho ${#:-foo} expect $0: '${#:}: bad substitution' @@ -540,12 +533,6 @@ recho "${RECEIVED:$((${#RECEIVED}-1)):1}" RECEIVED="" recho "${RECEIVED:$((${#RECEIVED}-1)):1}" -# tests of new prefix expansion ${!prefix*} -${THIS_SH} ./new-exp3.sub - -# bug with indirect expansion through bash-2.05b -${THIS_SH} ./new-exp4.sub - # these caused errors and core dumps in versions before bash-2.04 c="" echo ${c//${$(($#-1))}/x/} @@ -587,8 +574,6 @@ recho ${1%%[!/]*} recho ${1#*/} recho ${1##*/} -${THIS_SH} ./new-exp5.sub - unset var var=blah @@ -608,37 +593,6 @@ echo ${var[*]//#abc/foo} echo ${var[*]/#abc/foo} unset var -${THIS_SH} ./new-exp6.sub - -${THIS_SH} ./new-exp7.sub - -${THIS_SH} ./new-exp8.sub - -# tests to check whether things like indirect expansion of a variable whose -# value is 'anothervar[@]' stop working -${THIS_SH} ./new-exp9.sub - -# new parameter transformation `@' expansion operator -${THIS_SH} ./new-exp10.sub - -# parameter substring replacement and removal operators with multibyte chars -${THIS_SH} ./new-exp11.sub - -# indirect expansion with arrays and local variables -${THIS_SH} ./new-exp12.sub - -# more indirect expansion and parameter transformation issues -${THIS_SH} ./new-exp13.sub - -# new K parameter transformation operator -${THIS_SH} ./new-exp14.sub - -# ongoing work with a/A parameter transformations and `nounset' -${THIS_SH} ./new-exp15.sub - -# pattern substitution with `&' (quoted and unquoted) in the replacement string -${THIS_SH} ./new-exp16.sub - # problems with stray CTLNUL in bash-4.0-alpha unset a @@ -667,5 +621,53 @@ echo "${b/\/#/%%}" unset a b +# run process substitution tests in a subshell so that syntax errors +# caused by a shell not implementing process substitution (e.g., one +# built on a NeXT) will not cause the whole test to exit prematurely +test_runsub ./new-exp1.sub + +# run the tests of $( argv[1] = <$'a\tb\tc'> AD E + nquote1.sub hello' world hello world! hello' world! + nquote2.sub ' | ' ' | ' x | x @@ -60,14 +62,17 @@ $'\'' $'\'abcd\'' ' 1 + nquote3.sub argv[1] = <^?> 0000000 del nl 0000002 0000000 esc fs gs rs us del nl 0000007 \q + nquote4.sub foo ./nquote4.sub: line 6: quux: command not found + nquote5.sub argv[1] = argv[1] = argv[1] = <^A> diff --git a/tests/nquote.tests b/tests/nquote.tests index e4d1a56f..97224a00 100644 --- a/tests/nquote.tests +++ b/tests/nquote.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# expect() { echo expect "$@" @@ -135,8 +137,8 @@ recho "$'a\tb\tc'" # tests for $'...' being expanded in command substitution, and when echo "$(echo $'\t\t\101\104\n\105')" -${THIS_SH} ./nquote1.sub -${THIS_SH} ./nquote2.sub -${THIS_SH} ./nquote3.sub -${THIS_SH} ./nquote4.sub -${THIS_SH} ./nquote5.sub +test_runsub ./nquote1.sub +test_runsub ./nquote2.sub +test_runsub ./nquote3.sub +test_runsub ./nquote4.sub +test_runsub ./nquote5.sub diff --git a/tests/parser.right b/tests/parser.right index 6424dba6..673c55ce 100644 --- a/tests/parser.right +++ b/tests/parser.right @@ -1,5 +1,7 @@ bash: -c: line 1: unexpected EOF while looking for matching `)' + parser1.sub AAA + posix2syntax.sub bash5: line 1: `invalid-name': not a valid identifier in in diff --git a/tests/parser.tests b/tests/parser.tests index 51f56685..60e4437b 100644 --- a/tests/parser.tests +++ b/tests/parser.tests @@ -1,4 +1,5 @@ # catch-all for parsing problems that don't fit anywhere else +. ./test-aux-functions # word_top issues in bash-5.2 case x in x) if ((1)); then :; fi ;; esac @@ -11,6 +12,6 @@ case x in x) if ((true ) ); then :; fi esac ${THIS_SH} -c '((X=([))]' bash # this has to be in a separate file to get desired EOF behavior -${THIS_SH} ./parser1.sub +test_runsub ./parser1.sub -${THIS_SH} ./posix2syntax.sub +test_runsub ./posix2syntax.sub diff --git a/tests/posixexp.right b/tests/posixexp.right index 7204b960..6d8f3f76 100644 --- a/tests/posixexp.right +++ b/tests/posixexp.right @@ -37,6 +37,10 @@ argv[1] = <'bar> argv[1] = argv[1] = <}z> argv[1] = <''z}> + posixexp1.sub + posixexp1.sub + posixexp2.sub + posixexp3.sub argv[1] = <1> argv[2] = <2> argv[1] = <1> @@ -79,6 +83,7 @@ argv[1] = <1 2> argv[1] = <1 2> argv[1] = <12> argv[1] = <12> + posixexp4.sub normal IFS argv[1] = argv[2] = @@ -112,6 +117,7 @@ argv[2] = argv[3] = argv[1] = < abc def ghi jkl > argv[1] = < abc def ghi jkl > + posixexp5.sub 001: IFS = (unset): unset -v foo; set -- ${foo=$*} soh stx etx del / soh stx etx del @@ -256,6 +262,7 @@ soh stx etx del / soh stx etx del 048: IFS = sp ht nl: foo=; set -- "${foo:=$@}" soh stx etx del / soh stx etx del + posixexp6.sub argv[1] = <^A^B^C^?> argv[1] = <^A^B^C^?> argv[1] = <^A^B^C^?> @@ -275,6 +282,7 @@ argv[2] = [ abc def ghi jkl / abc def ghi jkl ] [ abc def ghi jkl ] [ abc def ghi jkl / abc def ghi jkl / abc def ghi jkl ] + posixexp7.sub 1: OK 2: $'not' 3: OK @@ -300,9 +308,10 @@ tOK ./posixexp7.sub: line 70: ${'x1'%'t'}: bad substitution ./posixexp7.sub: line 73: ${'x1'%'t'}: bad substitution ./posixexp7.sub: line 74: ${'x1'%'t'}: bad substitution + posixexp8.sub "A" A argv[1] = <"A"> argv[1] = argv[1] = -./posixexp.tests: line 97: unexpected EOF while looking for matching `}' +./posixexp.tests: line 101: unexpected EOF while looking for matching `}' diff --git a/tests/posixexp.tests b/tests/posixexp.tests index d8f66441..8f595d07 100644 --- a/tests/posixexp.tests +++ b/tests/posixexp.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# unset a printf "%s\n" ${a:=a\ b} echo "$a" @@ -79,18 +81,20 @@ recho "${IFS+'}'z}" : ${TMPDIR:=/var/tmp} rm -f $TMPDIR/sh cp ${THIS_SH} $TMPDIR/sh -THIS_SH=$TMPDIR/sh ${THIS_SH} ./posixexp1.sub || echo "sh posixexp1.sub: test $? failed" -${THIS_SH} ./posixexp1.sub || echo "bash posixexp1.sub: test $? failed" +THIS_SH=$TMPDIR/sh test_runsub ./posixexp1.sub || echo "sh posixexp1.sub: test $? failed" +test_runsub ./posixexp1.sub || echo "bash posixexp1.sub: test $? failed" -THIS_SH=$TMPDIR/sh ${THIS_SH} ./posixexp2.sub || echo "sh posixexp2.sub: test $? failed" +THIS_SH=$TMPDIR/sh test_runsub ./posixexp2.sub || echo "sh posixexp2.sub: test $? failed" rm -f $TMPDIR/sh -${THIS_SH} ./posixexp3.sub -${THIS_SH} ./posixexp4.sub -${THIS_SH} ./posixexp5.sub -${THIS_SH} ./posixexp6.sub -${THIS_SH} ./posixexp7.sub -${THIS_SH} ./posixexp8.sub +. ./test-aux-functions + +test_runsub ./posixexp3.sub +test_runsub ./posixexp4.sub +test_runsub ./posixexp5.sub +test_runsub ./posixexp6.sub +test_runsub ./posixexp7.sub +test_runsub ./posixexp8.sub # this will be an error foo=bar diff --git a/tests/printf.right b/tests/printf.right index 1816837a..9674f182 100644 --- a/tests/printf.right +++ b/tests/printf.right @@ -1,10 +1,10 @@ printf: usage: printf [-v var] format [arguments] printf: usage: printf [-v var] format [arguments] -./printf.tests: line 44: printf: -x: invalid option +./printf.tests: line 46: printf: -x: invalid option printf: usage: printf [-v var] format [arguments] -./printf.tests: line 47: printf: `invalid-var': not a valid identifier +./printf.tests: line 49: printf: `invalid-var': not a valid identifier abc -./printf.tests: line 48: printf: `invalid-var': not a valid identifier +./printf.tests: line 50: printf: `invalid-var': not a valid identifier 10 one one\ctwo @@ -40,7 +40,7 @@ A7 --\"abcd\"-- --\'abcd\'-- --a\x-- -./printf.tests: line 133: printf: missing hex digit for \x +./printf.tests: line 135: printf: missing hex digit for \x --\x-- ---- ---- @@ -101,12 +101,12 @@ A7 26 26 26 -./printf.tests: line 257: printf: `%10': missing format character -./printf.tests: line 258: printf: `M': invalid format character -ab./printf.tests: line 261: printf: `y': invalid format character -./printf.tests: line 264: printf: GNU: invalid number +./printf.tests: line 259: printf: `%10': missing format character +./printf.tests: line 260: printf: `M': invalid format character +ab./printf.tests: line 263: printf: `y': invalid format character +./printf.tests: line 266: printf: GNU: invalid number 0 -./printf.tests: line 265: printf: GNU: invalid number +./printf.tests: line 267: printf: GNU: invalid number 0 - (foo )(bar ) @@ -167,12 +167,13 @@ xx '' 9223372036854775807 -9223372036854775808 -./printf.tests: line 386: printf: +: invalid number +./printf.tests: line 388: printf: +: invalid number 0 -./printf.tests: line 387: printf: z: invalid number +./printf.tests: line 389: printf: z: invalid number 0 -./printf.tests: line 388: printf: : invalid number +./printf.tests: line 390: printf: : invalid number 0 + printf1.sub one one\ctwo 4\.2 @@ -277,6 +278,8 @@ A7 ^G ^Ge "? + printf2.sub + printf3.sub 16:09:15 ./printf3.sub: line 27: printf: warning: `Z': invalid time format specification %(abde)Z @@ -288,6 +291,7 @@ random time: 2010-05-30 04:09:15 PM -0400 local time: Sun May 30 16:09:15 EDT 2010 Sun May 30 16:09:15 EDT 2010 date-style time 05/30/10 (foo) 16:09:15 date-style time + printf4.sub x 123x x 123x x 123x @@ -322,6 +326,7 @@ x +123x x +123x x +123x x +123x + printf5.sub abcd ab 123 @@ -342,6 +347,7 @@ hello -- hello -- 123 -- 6 -- + printf6.sub 0000000 000 0000001 0000000 000 @@ -372,6 +378,7 @@ hello -- 0000000 340 262 207 040 040 040 055 055 055 012 000000a [][] + printf7.sub [] [X] VAR=[] diff --git a/tests/printf.tests b/tests/printf.tests index b8c2196b..15ab5dc7 100644 --- a/tests/printf.tests +++ b/tests/printf.tests @@ -17,6 +17,8 @@ LC_NUMERIC=C : ${TMPDIR:=/tmp} TMPF=$TMPDIR/printf-oflow-$RANDOM +. ./test-aux-functions + printf_overflow () { local r; @@ -388,11 +390,11 @@ printf '%d\n' z printf '%d\n' '' # tests variable assignment with -v -${THIS_SH} ./printf1.sub -${THIS_SH} ./printf2.sub -${THIS_SH} ./printf3.sub -${THIS_SH} ./printf4.sub -${THIS_SH} ./printf5.sub +test_runsub ./printf1.sub +test_runsub ./printf2.sub +test_runsub ./printf3.sub +test_runsub ./printf4.sub +test_runsub ./printf5.sub # multibyte characters with %ls/%S and %lc/%C -${THIS_SH} ./printf6.sub -${THIS_SH} ./printf7.sub +test_runsub ./printf6.sub +test_runsub ./printf7.sub diff --git a/tests/procsub.right b/tests/procsub.right index c6471c51..535be834 100644 --- a/tests/procsub.right +++ b/tests/procsub.right @@ -25,7 +25,9 @@ extern 0 0 0 + procsub1.sub 123 + procsub2.sub bar1 ouch bar2 diff --git a/tests/procsub.tests b/tests/procsub.tests index 140f6e70..f3485b23 100644 --- a/tests/procsub.tests +++ b/tests/procsub.tests @@ -117,5 +117,5 @@ moo() { ls -al "$1" >/dev/null; (true); ls -al "$1" >/dev/null; }; moo >(true) unset -f moo -${THIS_SH} ./procsub1.sub -${THIS_SH} ./procsub2.sub +test_runsub ./procsub1.sub +test_runsub ./procsub2.sub diff --git a/tests/quote.right b/tests/quote.right index bf9aba0d..81400886 100644 --- a/tests/quote.right +++ b/tests/quote.right @@ -74,6 +74,7 @@ string \ string \} escape\ escape\ + quote1.sub 'weferfds'\''dsfsdf' 'weferfdsdsfsdf' 'weferfds'\''dsfsdf' @@ -88,6 +89,7 @@ test'string a'b'c foo b c baz foo 'bar baz + quote2.sub argv[1] = <> argv[1] = <> argv[1] = <> @@ -130,6 +132,7 @@ argv[2] = <> argv[1] = <> argv[2] = <> argv[1] = <> + quote3.sub argv[1] = <4> argv[2] = <> argv[1] = @@ -144,6 +147,7 @@ argv[1] = argv[1] = argv[1] = argv[1] = + quote4.sub 0 1 1 diff --git a/tests/quote.tests b/tests/quote.tests index f454f8b0..2422349e 100644 --- a/tests/quote.tests +++ b/tests/quote.tests @@ -135,12 +135,14 @@ echo ${foo:-string \\\}} : ${TMPDIR:=/tmp} +. ./test-aux-functions + ${THIS_SH} -c 'echo escape\' printf 'echo escape\' > $TMPDIR/quote-$$ ${THIS_SH} $TMPDIR/quote-$$ rm -f $TMPDIR/quote-$$ -${THIS_SH} ./quote1.sub -${THIS_SH} ./quote2.sub -${THIS_SH} ./quote3.sub -${THIS_SH} ./quote4.sub +test_runsub ./quote1.sub +test_runsub ./quote2.sub +test_runsub ./quote3.sub +test_runsub ./quote4.sub diff --git a/tests/quotearray.right b/tests/quotearray.right index a75ef52a..208b067d 100644 --- a/tests/quotearray.right +++ b/tests/quotearray.right @@ -1,9 +1,9 @@ declare -A assoc=(["x],b[\$(echo uname >&2)"]="1" ) declare -A assoc=(["\$key"]="1" ["x],b[\$(echo uname >&2)"]="1" ) declare -A assoc=(["\$key"]="1" ["x],b[\$(echo uname >&2)"]="2" ) -./quotearray.tests: line 31: ((: 'assoc[x\],b\[\$(echo uname >&2)]++' : arithmetic syntax error: operand expected (error token is "'assoc[x\],b\[\$(echo uname >&2)]++' ") +./quotearray.tests: line 32: ((: 'assoc[x\],b\[\$(echo uname >&2)]++' : arithmetic syntax error: operand expected (error token is "'assoc[x\],b\[\$(echo uname >&2)]++' ") declare -A assoc=(["\$key"]="1" ["x],b[\$(echo uname >&2)"]="2" ) -./quotearray.tests: line 34: ((: 'assoc[x\],b\[\$(echo uname >&2)]'++ : arithmetic syntax error: operand expected (error token is "'assoc[x\],b\[\$(echo uname >&2)]'++ ") +./quotearray.tests: line 35: ((: 'assoc[x\],b\[\$(echo uname >&2)]'++ : arithmetic syntax error: operand expected (error token is "'assoc[x\],b\[\$(echo uname >&2)]'++ ") declare -A assoc=(["\$key"]="1" ["x],b[\$(echo uname >&2)"]="2" ) declare -A assoc=(["\$key"]="1" ["x],b[\$(echo uname >&2)"]="3" ) 4 @@ -24,15 +24,16 @@ declare -a a=([0]="12" [1]="42") declare -Ai assoc=(["']"]="3" ["\$var"]="1" ) 105 declare -A assoc=(["\` echo >&2 foo\`"]="42" ["\$( echo >&2 bar)"]="63" ) -./quotearray.tests: line 140: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)") -./quotearray.tests: line 144: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)") +./quotearray.tests: line 141: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)") +./quotearray.tests: line 145: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)") 1 -./quotearray.tests: line 147: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)") +./quotearray.tests: line 148: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)") 1 -./quotearray.tests: line 150: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)") +./quotearray.tests: line 151: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)") 1 -./quotearray.tests: line 153: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)") +./quotearray.tests: line 154: x],b[$(echo uname >&2): arithmetic syntax error: invalid arithmetic operator (error token is "],b[$(echo uname >&2)") 1 + quotearray1.sub declare -A assoc 0 0 @@ -62,6 +63,7 @@ foo [[ -v assoc[a] ]]; $?=0 [[ -v assoc["] ]]; $?=0 declare -A assoc=(["\""]="123" [a]="123" ) + quotearray2.sub declare -A a=([1]="1" [0]="0" [" "]="11" ) 7 7 @@ -79,6 +81,7 @@ declare -A A=(["*"]="X" ["@"]="X" ) declare -A assoc declare -A assoc=(["\$(echo foo)"]="1" ) 0 + quotearray3.sub declare -A assoc=(["\$var"]="value" ) declare -A assoc=(["\$var"]="value" ) declare -A assoc=(["\$var"]="value" ) @@ -100,6 +103,7 @@ declare -A map=(["foo\$(uname >/dev/tty)bar"]="1" ) declare -A map=() $(DOESNOTEXIST) declare -A blah=() + quotearray4.sub declare -A assoc=(["*"]="star" ["!"]="bang" ["@"]="at" ) declare -A assoc=(["*"]="star" ["!"]="bang" ) declare -A assoc=(["!"]="bang" ) @@ -127,6 +131,7 @@ declare -a array=([0]="1" [1]="2" [2]="3") 0 ./quotearray4.sub: line 115: array[@]: bad array subscript declare -a array=([0]="1" [1]="2" [2]="3") + quotearray5.sub ./quotearray5.sub: line 27: unset: `a[$(echo': not a valid identifier ./quotearray5.sub: line 27: unset: `foo)]': not a valid identifier declare -A a=() diff --git a/tests/quotearray.tests b/tests/quotearray.tests index e1ed83b0..c95c976a 100644 --- a/tests/quotearray.tests +++ b/tests/quotearray.tests @@ -13,6 +13,7 @@ # # a set of tests for associative arrays in arithmetic contexts +. ./test-aux-functions declare -A assoc key='x],b[$(echo uname >&2)' @@ -153,12 +154,12 @@ echo $? (( expr )) echo $? -${THIS_SH} ./quotearray1.sub -${THIS_SH} ./quotearray2.sub -${THIS_SH} ./quotearray3.sub +test_runsub ./quotearray1.sub +test_runsub ./quotearray2.sub +test_runsub ./quotearray3.sub # behavior of builtins with array subscripts @ and * -${THIS_SH} ./quotearray4.sub +test_runsub ./quotearray4.sub # behavior of unset with quoted and unquoted array arguments -${THIS_SH} ./quotearray5.sub +test_runsub ./quotearray5.sub diff --git a/tests/read.right b/tests/read.right index 277a02b6..17d05185 100644 --- a/tests/read.right +++ b/tests/read.right @@ -31,8 +31,9 @@ argv[1] = < foo> argv[1] = argv[1] = argv[1] = < foo> -./read.tests: line 101: b: readonly variable +./read.tests: line 103: b: readonly variable a = a b = c = stat = 2 + read1.sub a = abcdefg xyz a = xyz @@ -52,6 +53,7 @@ a = abc <$'spring\375'> + read2.sub timeout 1: ok unset or null 1 timeout 2: ok @@ -64,6 +66,7 @@ unset or null 3 abcde abcde abcde + read3.sub ./read3.sub: line 17: read: -1: invalid number abc defg @@ -71,10 +74,12 @@ ab abc # 0 + read4.sub while read -u 3 var do echo "$var" done 3<$0 + read5.sub argv[1] = <> argv[1] = <> argv[1] = <> @@ -86,9 +91,11 @@ argv[2] = <> argv[3] = <> FOO 0 0 0 + read6.sub 0 0 1 + read7.sub timeout 1: ok unset or null 1 timeout 2: ok @@ -99,10 +106,13 @@ timeout 4: ok abcde abcde + read8.sub one two three four one two three four + read9.sub + read10.sub IFS=[,] var=[abc] rest=[def,ghi] IFS=[] var=[abc] rest=[def,ghi] IFS=[ ] var=[ abc] rest=[def,ghi ] diff --git a/tests/read.tests b/tests/read.tests index c06cd7a7..6015da73 100644 --- a/tests/read.tests +++ b/tests/read.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# echo " a " | (read x; echo "$x.") echo " a b " | ( read x y ; echo -"$x"-"$y"- ) @@ -106,31 +108,31 @@ EOF echo a = $a b = $b c = $c stat = $? # test read -d delim behavior -${THIS_SH} ./read1.sub +test_runsub ./read1.sub # test read -t timeout behavior -${THIS_SH} ./read2.sub +test_runsub ./read2.sub # test read -n nchars behavior -${THIS_SH} ./read3.sub +test_runsub ./read3.sub # test read -u fd behavior -${THIS_SH} ./read4.sub +test_runsub ./read4.sub # test behavior when IFS is not the default -- bug through bash-2.05b -${THIS_SH} ./read5.sub +test_runsub ./read5.sub # test behavior of read -t 0 -${THIS_SH} ./read6.sub +test_runsub ./read6.sub # test behavior of readline timeouts -${THIS_SH} ./read7.sub +test_runsub ./read7.sub # test behavior of read -n and read -d on regular files -${THIS_SH} ./read8.sub +test_runsub ./read8.sub # test behavior of trailing IFS whitespace - POSIX conformance -${THIS_SH} ./read9.sub +test_runsub ./read9.sub # test behavior of read builtin modifying $IFS -${THIS_SH} ./read10.sub +test_runsub ./read10.sub diff --git a/tests/redir.right b/tests/redir.right index b3f1ba28..f96ba015 100644 --- a/tests/redir.right +++ b/tests/redir.right @@ -1,13 +1,13 @@ abc -./redir.tests: line 31: /tmp/redir-test: cannot overwrite existing file +./redir.tests: line 32: /tmp/redir-test: cannot overwrite existing file abc def def ghi -./redir.tests: line 52: -1: ambiguous redirect -./redir.tests: line 53: exec: -1: invalid option +./redir.tests: line 53: -1: ambiguous redirect +./redir.tests: line 54: exec: -1: invalid option exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...] -./redir.tests: line 58: $z: ambiguous redirect +./redir.tests: line 59: $z: ambiguous redirect Point 1 Point 2 to a @@ -20,12 +20,15 @@ to b Point 4 to c Point 5 + redir1.sub this is redir1.sub this is redir2.sub + redir3.sub read line1 "ab" read line2 "root" read line3 "cd" read line4 "daemon" + redir4.sub from stdin: aa to stdout ./redir4.sub: line 45: $fd: ambiguous redirect @@ -48,7 +51,8 @@ kl ab cd cd -./redir.tests: line 184: redir1.*: No such file or directory +./redir.tests: line 186: redir1.*: No such file or directory + redir5.sub # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or @@ -103,6 +107,7 @@ f () } after read # This program is free software: you can redistribute it and/or modify + redir6.sub / / / @@ -111,10 +116,12 @@ after read 0 before block after block + redir7.sub c1 is 1 c2 is 2 c3 is 3 c4 is 4 + redir8.sub fd 10 fd 8 fd 10 @@ -131,6 +138,7 @@ fd 8 4 cat /tmp/foo whatsis + redir9.sub hey to stdout to stderr @@ -158,7 +166,9 @@ bix () foo foo foo + redir10.sub :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + redir11.sub 1 7 after: 42 @@ -169,6 +179,7 @@ foo foo ./redir11.sub: line 77: 42: No such file or directory 42 + redir12.sub ./redir12.sub: line 27: unwritable-file: Permission denied 1 x = ./redir12.sub: line 31: unwritable-file: cannot overwrite existing file diff --git a/tests/redir.tests b/tests/redir.tests index a17da0fc..4790dae8 100644 --- a/tests/redir.tests +++ b/tests/redir.tests @@ -12,6 +12,7 @@ # along with this program. If not, see . # : ${TMPDIR:=/tmp} +. ./test-aux-functions export LC_ALL=C export LANG=C @@ -92,13 +93,14 @@ rm -f $TMPDIR/bash-a $TMPDIR/bash-b $TMPDIR/bash-c # # Test the effect of input buffering on the shell's input # +printf '\tredir1.sub\n' ${THIS_SH} < redir1.sub # more open, close, duplicate file descriptors -${THIS_SH} ./redir3.sub < ./redir3.in1 +test_runsub ./redir3.sub < ./redir3.in1 # still more redirections -${THIS_SH} ./redir4.sub < redir4.in1 +test_runsub ./redir4.sub < redir4.in1 # various forms of null redirection testf() @@ -184,10 +186,10 @@ set -o posix cat < redir1.* # test ksh93 dup-and-close (move fd) redirections -${THIS_SH} ./redir5.sub +test_runsub ./redir5.sub # test behavior after a write error with a builtin command -${THIS_SH} ./redir6.sub +test_runsub ./redir6.sub # problem with redirections using fds bash uses internally : ${TMPDIR:=$TMPDIR} @@ -203,9 +205,9 @@ echo before block echo after block -${THIS_SH} ./redir7.sub +test_runsub ./redir7.sub -${THIS_SH} ./redir8.sub +test_runsub ./redir8.sub exec 9>&2 command exec 2>>$TMPDIR/foo-$$ @@ -216,9 +218,9 @@ rm -f $TMPDIR/foo-$$ exec 2>&9 exec 9>&- -${THIS_SH} ./redir9.sub -${THIS_SH} ./redir10.sub -${THIS_SH} ./redir11.sub -${THIS_SH} ./redir12.sub +test_runsub ./redir9.sub +test_runsub ./redir10.sub +test_runsub ./redir11.sub +test_runsub ./redir12.sub ${THIS_SH} < ./redir13.in diff --git a/tests/rhs-exp.right b/tests/rhs-exp.right index 4ce6743e..6b930bba 100644 --- a/tests/rhs-exp.right +++ b/tests/rhs-exp.right @@ -72,6 +72,7 @@ a?b ab a/b ab + rhs-exp1.sub argv[1] = argv[1] = argv[1] = diff --git a/tests/rhs-exp.tests b/tests/rhs-exp.tests index 6abdd2a7..c5656813 100644 --- a/tests/rhs-exp.tests +++ b/tests/rhs-exp.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions +# selvecs='&m68kcoff_vec' recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'}" recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'$selvecs\'}" @@ -61,4 +63,4 @@ var="a?b" ; echo "${var//\?/}" var="a/b" ; echo "${var//\\//}" var="a/b" ; echo "${var//\//}" -${THIS_SH} ./rhs-exp1.sub +test_runsub ./rhs-exp1.sub diff --git a/tests/rsh.right b/tests/rsh.right index e9a4ae6a..cb8bfe5d 100644 --- a/tests/rsh.right +++ b/tests/rsh.right @@ -1,20 +1,22 @@ + rsh1.sub ./rsh1.sub: line 22: /bin/sh: restricted ./rsh1.sub: line 24: sh: not found ./rsh1.sub: line 25: a: command not found + rsh2.sub ./rsh2.sub: line 23: hash: /bin/sh: restricted ./rsh2.sub: line 25: hash: sh: not found ./rsh2.sub: line 26: a: command not found -./rsh.tests: line 25: cd: restricted -./rsh.tests: line 26: PATH: readonly variable -./rsh.tests: line 27: SHELL: readonly variable -./rsh.tests: line 28: /bin/sh: restricted: cannot specify `/' in command names -./rsh.tests: line 29: /bin/cat: restricted: cannot specify `/' in command names -./rsh.tests: line 31: .: ./source.sub3: restricted -./rsh.tests: line 34: /tmp/restricted: restricted: cannot redirect output -./rsh.tests: line 38: /tmp/restricted: restricted: cannot redirect output -./rsh.tests: line 43: command: -p: restricted -./rsh.tests: line 45: set: +r: invalid option +./rsh.tests: line 26: cd: restricted +./rsh.tests: line 27: PATH: readonly variable +./rsh.tests: line 28: SHELL: readonly variable +./rsh.tests: line 29: /bin/sh: restricted: cannot specify `/' in command names +./rsh.tests: line 30: /bin/cat: restricted: cannot specify `/' in command names +./rsh.tests: line 32: .: ./source.sub3: restricted +./rsh.tests: line 35: /tmp/restricted: restricted: cannot redirect output +./rsh.tests: line 39: /tmp/restricted: restricted: cannot redirect output +./rsh.tests: line 44: command: -p: restricted +./rsh.tests: line 46: set: +r: invalid option set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...] -./rsh.tests: line 46: set: restricted: invalid option name -./rsh.tests: line 48: exec: restricted +./rsh.tests: line 47: set: restricted: invalid option name +./rsh.tests: line 49: exec: restricted ./rsh.tests: after exec diff --git a/tests/rsh.tests b/tests/rsh.tests index 491608bf..6f87fb50 100644 --- a/tests/rsh.tests +++ b/tests/rsh.tests @@ -12,13 +12,14 @@ # along with this program. If not, see . # # test restricted shell mode -- these should all be errors +. ./test-aux-functions # # things not tested for: # adding builtins dynamically with enable -f # importing function definitions from environment -${THIS_SH} ./rsh1.sub -${THIS_SH} ./rsh2.sub +test_runsub ./rsh1.sub +test_runsub ./rsh2.sub set -r diff --git a/tests/run-all b/tests/run-all index f9dfa604..6201f7b1 100644 --- a/tests/run-all +++ b/tests/run-all @@ -56,15 +56,52 @@ ${THIS_SH} ./version rm -f ${BASH_TSTOUT} +export TAB=' ' + echo Any output from any test, unless otherwise noted, indicates a possible anomaly +# keep track of passed and failed tests and report them +if [ -t 1 ]; then + # can't rely on having $'...' or printf understanding \e + # bright red background, white foreground text + CSTART=$(printf '\033[01;101;37m') CEND=$(printf '\033[0m') +else + CSTART= CEND= +fi + +passed=0 +total=0 +failed=0 + +if [ -n "$BASH_TSTOUT_SAVEDIR" ] && [ -d "$BASH_TSTOUT_SAVEDIR" ]; then + echo "Using $BASH_TSTOUT_SAVEDIR to save output from failed tests" +else + unset BASH_TSTOUT_SAVEDIR +fi + for x in run-* do case $x in $0|run-minimal|run-gprof) ;; - *.orig|*~) ;; - *) echo $x ; sh $x ; rm -f ${BASH_TSTOUT} ;; + *.orig|*.save|*~) ;; + *) echo $x + total=$(( $total + 1 )) + if sh $x; then + passed=$(( $passed + 1 )) + else + failed=$(( $failed + 1 )) + echo "${CSTART}${x}: NON-ZERO exit status $?${CEND}" + if [ -n "$BASH_TSTOUT_SAVEDIR" ]; then + mv ${BASH_TSTOUT} ${BASH_TSTOUT_SAVEDIR}/${x}-${SUFFIX} + echo "${CSTART}output saved to ${BASH_TSTOUT_SAVEDIR}/${x}-${SUFFIX}${CEND}" + elif [ $failed -eq 1 ]; then + echo "${CSTART}Set environment variable BASH_TSTOUT_SAVEDIR to a directory to save failed test output${CEND}" + fi + fi + rm -f ${BASH_TSTOUT} + ;; esac done -exit 0 +echo "${CSTART}${passed}/${total} tests succeeded${CEND}" +exit $failed diff --git a/tests/run-array b/tests/run-array index 6c5ec277..5de82916 100644 --- a/tests/run-array +++ b/tests/run-array @@ -1,6 +1,6 @@ echo "warning: all of these tests will fail if arrays have not" >&2 -echo "warning: been compiled into the shell" >&2 -echo "warning: the BASH_ARGC and BASH_ARGV tests will fail if debugging support" >&2 -echo "warning: has not been compiled into the shell" >&2 +echo "${TAB}been compiled into the shell" >&2 +echo "warning: the BASH_ARGC and BASH_ARGV tests will fail if debugging" >&2 +echo "${TAB}support has not been compiled into the shell" >&2 ${THIS_SH} ./array.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} array.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-array2 b/tests/run-array2 index 54852ec9..e0fe49b2 100644 --- a/tests/run-array2 +++ b/tests/run-array2 @@ -1,4 +1,4 @@ echo "warning: all of these tests will fail if arrays have not" >&2 -echo "warning: been compiled into the shell" >&2 +echo "${TAB}been compiled into the shell" >&2 ${THIS_SH} ./array-at-star > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} array2.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-assoc b/tests/run-assoc index 7fef2344..d840e72a 100644 --- a/tests/run-assoc +++ b/tests/run-assoc @@ -1,4 +1,4 @@ echo "warning: all of these tests will fail if arrays have not" >&2 -echo "warning: been compiled into the shell" >&2 +echo "${TAB}been compiled into the shell" >&2 ${THIS_SH} ./assoc.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} assoc.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-builtins b/tests/run-builtins index 69644f27..0ee115a1 100644 --- a/tests/run-builtins +++ b/tests/run-builtins @@ -1,6 +1,6 @@ echo "warning: some of these tests may fail if process substitution has not" >&2 -echo "warning: been compiled into the shell or if the OS does not provide" >&2 -echo "warning: /dev/fd." >&2 +echo "${TAB}been compiled into the shell or if the OS does not provide" >&2 +echo "${TAB}/dev/fd." >&2 ${THIS_SH} ./builtins.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} builtins.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-cond b/tests/run-cond index 2cbc86ac..afa0f14b 100644 --- a/tests/run-cond +++ b/tests/run-cond @@ -1,9 +1,9 @@ echo "warning: all of these tests will fail if the conditional command has not" >&2 -echo "warning: been compiled into the shell" >&2 +echo "${TAB}been compiled into the shell" >&2 echo "warning: some of these tests will fail if extended pattern matching has not" >&2 -echo "warning: been compiled into the shell" >&2 +echo "${TAB}been compiled into the shell" >&2 echo "warning: the text of system error messages may vary between systems and" >&2 -echo "warning: produce diff output." >&2 +echo "${TAB}produce diff output." >&2 ${THIS_SH} ./cond.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} cond.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-dbg-support b/tests/run-dbg-support index af64517d..0b286d81 100644 --- a/tests/run-dbg-support +++ b/tests/run-dbg-support @@ -1,6 +1,5 @@ - TEST_NAME='dbg-support' -TEST_FILE="/tmp/${TEST_NAME}.check" +TEST_FILE="${BASH_TSTOUT}" ${THIS_SH} ./${TEST_NAME}.tests > $TEST_FILE 2>&1 < /dev/null set -f diff $TEST_FILE ${TEST_NAME}.right && rm -f $TEST_FILE diff --git a/tests/run-dbg-support2 b/tests/run-dbg-support2 index 375c32f9..676cc267 100644 --- a/tests/run-dbg-support2 +++ b/tests/run-dbg-support2 @@ -1,6 +1,6 @@ TEST_NAME='dbg-support2' -TEST_FILE="/tmp/${TEST_NAME}.check" +TEST_FILE="${BASH_TSTOUT}" ${THIS_SH} ./${TEST_NAME}.tests > $TEST_FILE 2>&1 < /dev/null set -f diff $TEST_FILE ${TEST_NAME}.right && rm -f $TEST_FILE diff --git a/tests/run-execscript b/tests/run-execscript index 4581a649..55c95392 100644 --- a/tests/run-execscript +++ b/tests/run-execscript @@ -13,11 +13,11 @@ # echo "warning: the text of a system error message may vary between systems and" >&2 -echo "warning: produce diff output." >&2 -echo "warning: if the text of the error messages concerning \`notthere' or" >&2 -echo "warning: \`/tmp/bash-notthere' not being found or \`/' being a directory" >&2 -echo "warning: produce diff output, please do not consider this a test failure" >&2 +echo "${TAB}produce diff output." >&2 +echo "${TAB}if the text of the error messages concerning \`notthere' or" >&2 +echo "${TAB}\`/tmp/bash-notthere' not being found or \`/' being a directory" >&2 +echo "${TAB}produce diff output, please do not consider this a test failure" >&2 echo "warning: if diff output differing only in the location of the bash" >&2 -echo "warning: binary appears, please do not consider this a test failure" >&2 +echo "${TAB}binary appears, please do not consider this a test failure" >&2 ${THIS_SH} ./execscript > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} exec.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-func b/tests/run-func index a804364f..aa8c8b12 100644 --- a/tests/run-func +++ b/tests/run-func @@ -1,5 +1,5 @@ echo "warning: if you have exported functions defined in your environment," >&2 -echo "warning: they may show up as diff output." >&2 -echo "warning: if so, please do not consider this a test failure" >&2 +echo "${TAB}they may show up as diff output." >&2 +echo "${TAB}If so, please do not consider this a test failure" >&2 ${THIS_SH} ./func.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} func.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-glob-test b/tests/run-glob-test index 246501cc..3f91d19c 100644 --- a/tests/run-glob-test +++ b/tests/run-glob-test @@ -3,5 +3,5 @@ export PATH ( diff -a glob.right glob.right >/dev/null 2>&1 ) && AFLAG=-a -${THIS_SH} ./glob.tests > ${BASH_TSTOUT} 2>&1 +${THIS_SH} ./glob.tests > ${BASH_TSTOUT} # 2>&1 diff ${AFLAG} ${BASH_TSTOUT} glob.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-heredoc b/tests/run-heredoc index b655c4f8..80c98ac1 100644 --- a/tests/run-heredoc +++ b/tests/run-heredoc @@ -1,6 +1,6 @@ echo "warning: UNIX versions number signals and schedule processes differently." >&2 -echo "warning: If output differing only in line numbers is produced, please" >&2 -echo "warning: do not consider this a test failure." >&2 +echo "${TAB}If output differing only in line numbers is produced, please" >&2 +echo "${TAB}do not consider this a test failure." >&2 ${THIS_SH} ./heredoc.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} heredoc.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-histexpand b/tests/run-histexpand index a0fc3312..3618c2bc 100644 --- a/tests/run-histexpand +++ b/tests/run-histexpand @@ -1,4 +1,4 @@ echo "warning: all of these tests will fail if history has not been compiled" >&2 -echo "warning: into the shell" >&2 +echo "${TAB}into the shell" >&2 ${THIS_SH} ./histexp.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} histexp.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-history b/tests/run-history index f4fa4663..9334fd7f 100644 --- a/tests/run-history +++ b/tests/run-history @@ -1,4 +1,4 @@ echo "warning: all of these tests will fail if history has not been compiled" >&2 -echo "warning: into the shell" >&2 +echo "${TAB}into the shell" >&2 ${THIS_SH} ./history.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} history.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-jobs b/tests/run-jobs index 8429b0db..3d442973 100644 --- a/tests/run-jobs +++ b/tests/run-jobs @@ -1,7 +1,7 @@ echo "warning: some of these tests may fail if job control has not been compiled" >&2 -echo "warning: into the shell" >&2 +echo "${TAB}into the shell" >&2 echo "warning: there may be a message regarding a cat process dying due to a" >&2 -echo "warning: SIGHUP. Please disregard." >&2 +echo "${TAB}SIGHUP. Please disregard." >&2 ${THIS_SH} ./jobs.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} jobs.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-nameref b/tests/run-nameref index b73e1b8c..0d851b8c 100644 --- a/tests/run-nameref +++ b/tests/run-nameref @@ -1,4 +1,4 @@ echo "warning: some of these tests will fail if arrays have not" >&2 -echo "warning: been compiled into the shell" >&2 +echo "${TAB}been compiled into the shell" >&2 ${THIS_SH} ./nameref.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} nameref.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-new-exp b/tests/run-new-exp index 8777c7bd..15774e5b 100644 --- a/tests/run-new-exp +++ b/tests/run-new-exp @@ -1,10 +1,10 @@ echo "warning: two of these tests will fail if your OS does not support" >&2 -echo "warning: named pipes or the /dev/fd filesystem. If the tests of the" >&2 -echo "warning: process substitution mechanism fail, please do not consider" >&2 -echo "warning: this a test failure" >&2 +echo "${TAB}named pipes or the /dev/fd filesystem. If the tests of the" >&2 +echo "${TAB}process substitution mechanism fail, please do not consider" >&2 +echo "${TAB}this a test failure" >&2 echo "warning: if you have exported variables beginning with the string _Q," >&2 -echo "warning: diff output may be generated. If so, please do not consider" >&2 -echo "warning: this a test failure" >&2 +echo "${TAB}the tests may generate diff output. If so, please do not consider" >&2 +echo "${TAB}this a test failure" >&2 ${THIS_SH} ./new-exp.tests 2>&1 | grep -v '^expect' > ${BASH_TSTOUT} diff ${BASH_TSTOUT} new-exp.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-nquote1 b/tests/run-nquote1 index bd9e9398..6dd880a8 100644 --- a/tests/run-nquote1 +++ b/tests/run-nquote1 @@ -1,4 +1,4 @@ echo "warning: several of these tests will fail if arrays have not" >&2 -echo "warning: been compiled into the shell." >&2 +echo "${TAB}been compiled into the shell." >&2 ${THIS_SH} ./nquote1.tests 2>&1 | grep -v '^expect' > ${BASH_TSTOUT} diff ${BASH_TSTOUT} nquote1.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-nquote2 b/tests/run-nquote2 index 4648d3ee..f744445e 100644 --- a/tests/run-nquote2 +++ b/tests/run-nquote2 @@ -1,4 +1,4 @@ echo "warning: several of these tests will fail if arrays have not" >&2 -echo "warning: been compiled into the shell." >&2 +echo "${TAB}been compiled into the shell." >&2 ${THIS_SH} ./nquote2.tests 2>&1 | grep -v '^expect' > ${BASH_TSTOUT} diff ${BASH_TSTOUT} nquote2.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-nquote3 b/tests/run-nquote3 index 4a3e32af..f96f45ee 100644 --- a/tests/run-nquote3 +++ b/tests/run-nquote3 @@ -1,4 +1,4 @@ echo "warning: several of these tests will fail if arrays have not" >&2 -echo "warning: been compiled into the shell." >&2 +echo "${TAB}been compiled into the shell." >&2 ${THIS_SH} ./nquote3.tests 2>&1 | grep -v '^expect' > ${BASH_TSTOUT} diff ${BASH_TSTOUT} nquote3.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-nquote4 b/tests/run-nquote4 index 985c3111..07b083c7 100644 --- a/tests/run-nquote4 +++ b/tests/run-nquote4 @@ -1,8 +1,8 @@ # See whether or not we can use `diff -a' ( diff -a ./nquote4.right ./nquote4.right >/dev/null 2>&1 ) && AFLAG=-a -echo warning: some of these tests will fail if you do not have UTF-8 >&2 -echo warning: locales installed on your system >&2 +echo "warning: some of these tests will fail if you do not have UTF-8" >&2 +echo "${TAB}locales installed on your system" >&2 ${THIS_SH} ./nquote4.tests > ${BASH_TSTOUT} 2>&1 diff ${AFLAG} ${BASH_TSTOUT} nquote4.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-procsub b/tests/run-procsub index 796faaa8..c15d8002 100644 --- a/tests/run-procsub +++ b/tests/run-procsub @@ -1,7 +1,7 @@ echo "warning: all of these tests will fail if process substitution has not" >&2 -echo "warning: been compiled into the shell or if the OS does not provide" >&2 -echo "warning: FIFOs or /dev/fd. Some tests may fail if the OS does not" >&2 -echo "warning: provide FIFOs." >&2 +echo "${TAB}been compiled into the shell or if the OS does not provide" >&2 +echo "${TAB}FIFOs or /dev/fd. Some tests may fail if the OS does not" >&2 +echo "${TAB}provide FIFOs." >&2 ${THIS_SH} ./procsub.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} procsub.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-read b/tests/run-read index 5ec07e27..43746092 100644 --- a/tests/run-read +++ b/tests/run-read @@ -1,4 +1,4 @@ echo "warning: please do not consider output differing only in the amount of" >&2 -echo "warning: white space to be an error." >&2 +echo "${TAB}white space to be an error." >&2 ${THIS_SH} ./read.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} read.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-redir b/tests/run-redir index 071af6eb..04da6dd1 100644 --- a/tests/run-redir +++ b/tests/run-redir @@ -1,7 +1,7 @@ echo "warning: the text of a system error message may vary between systems and" >&2 -echo "warning: produce diff output." >&2 +echo "${TAB}produce diff output." >&2 echo "warning: if the text of an error message concerning \`redir1.*' not being" >&2 -echo "warning: found or messages concerning bad file descriptors produce diff" >&2 -echo "warning: output, please do not consider it a test failure" >&2 +echo "${TAB}found or messages concerning bad file descriptors produce diff" >&2 +echo "${TAB}output, please do not consider it a test failure" >&2 ${THIS_SH} ./redir.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} redir.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-trap b/tests/run-trap index e3331ed0..cfffd432 100644 --- a/tests/run-trap +++ b/tests/run-trap @@ -1,6 +1,6 @@ echo "warning: UNIX versions number signals and schedule processes differently." >&2 -echo "warning: If output differing only in line numbers is produced, please" >&2 -echo "warning: do not consider this a test failure." >&2 +echo "${TAB}If output differing only in line numbers is produced, please" >&2 +echo "${TAB}do not consider this a test failure." >&2 ${THIS_SH} ./trap.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} trap.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-varenv b/tests/run-varenv index be394cc7..270deba7 100644 --- a/tests/run-varenv +++ b/tests/run-varenv @@ -1,4 +1,4 @@ echo "warning: some of these tests will fail if arrays have not" >&2 -echo "warning: been compiled into the shell" >&2 +echo "${TAB}been compiled into the shell" >&2 ${THIS_SH} ./varenv.tests 2>&1 | grep -v '^expect' > ${BASH_TSTOUT} diff ${BASH_TSTOUT} varenv.right && rm -f ${BASH_TSTOUT} diff --git a/tests/run-vredir b/tests/run-vredir index 2bdc1b83..0a4d88b3 100644 --- a/tests/run-vredir +++ b/tests/run-vredir @@ -1,4 +1,4 @@ echo "warning: the text of a system error message may vary between systems and" >&2 -echo "warning: produce diff output." >&2 +echo "${TAB}produce diff output." >&2 ${THIS_SH} ./vredir.tests > ${BASH_TSTOUT} 2>&1 diff ${BASH_TSTOUT} vredir.right && rm -f ${BASH_TSTOUT} diff --git a/tests/set-e.right b/tests/set-e.right index d5bce867..506a78cb 100644 --- a/tests/set-e.right +++ b/tests/set-e.right @@ -35,6 +35,7 @@ b after 1 a 0 + set-e1.sub non-posix foo after brace group failure: 1 A 1 @@ -64,9 +65,11 @@ foo after failure 1 after failure 2 after failure 3 + set-e2.sub true || false no exit false || true no exit false && false no exit + set-e3.sub A: B: ehB diff --git a/tests/set-e.tests b/tests/set-e.tests index a0311be4..ccb63e82 100644 --- a/tests/set-e.tests +++ b/tests/set-e.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions + if : ; then set -e N=95 @@ -132,6 +134,6 @@ rm -f $FN set +e -${THIS_SH} ./set-e1.sub -${THIS_SH} ./set-e2.sub -${THIS_SH} ./set-e3.sub +test_runsub ./set-e1.sub +test_runsub ./set-e2.sub +test_runsub ./set-e3.sub diff --git a/tests/set-x.right b/tests/set-x.right index 7b14626d..76f98f31 100644 --- a/tests/set-x.right +++ b/tests/set-x.right @@ -34,6 +34,7 @@ onetwo + echo onetwo onetwo + set +x + set-x1.sub ./set-x1.sub: line 18: BASH_XTRACEFD: 4: invalid value for trace file descriptor 1 2 @@ -63,6 +64,7 @@ TRACEFILE: + echo 4 + unset BASH_XTRACEFD ===== + set-x2.sub + metas=(\| \& \; \( \) \< \> ' ' ' ' ' ') + n=($@) diff --git a/tests/set-x.tests b/tests/set-x.tests index b0b2ccca..70f85884 100644 --- a/tests/set-x.tests +++ b/tests/set-x.tests @@ -35,9 +35,10 @@ echo $foo foo=one echo $foo set +x +. ./test-aux-functions # test BASH_XTRACEFD -${THIS_SH} ./set-x1.sub +test_runsub ./set-x1.sub # compound assignment printing -${THIS_SH} ./set-x2.sub +test_runsub ./set-x2.sub diff --git a/tests/test-aux-functions b/tests/test-aux-functions index 869cb304..a577229d 100644 --- a/tests/test-aux-functions +++ b/tests/test-aux-functions @@ -17,18 +17,18 @@ test_runsub() scriptname=${1##*/} printf '\t%s\n' "${scriptname}" - ${THIS_SH} "$1" + ${THIS_SH} "$@" } # some useful locale variables ZH_LOCALE=$(locale -a | grep -i '^zh_TW\.big5' | sed 1q) -ZH_DEFAULT=$(locale | grep ^LC_CTYPE | sed 's:^.*=::' | tr -d '"') +ZH_DEFAULT=zh_TW.big5 US_LOCALE=$(locale -a | grep -i '^en_US\.utf-8' | sed 1q) if [ -z "$US_LOCALE" ]; then US_LOCALE=$(locale -a | grep -i '^en_US\.utf8' | sed 1q) fi -CTYPE_DEFAULT=$ZH_DEFAULT +CTYPE_DEFAULT=$(locale | grep ^LC_CTYPE | sed 's:^.*=::' | tr -d '"') # figure out default locale; use LC_CTYPE value since that is what we use it for if [ -n "$LC_ALL" ]; then diff --git a/tests/test.right b/tests/test.right index 522dd6e2..f4dd4fd2 100644 --- a/tests/test.right +++ b/tests/test.right @@ -255,83 +255,84 @@ t -G /tmp/test.group t -h /tmp/test.symlink 0 t 4+3 -eq 7 -./test.tests: line 26: test: 4+3: integer expected +./test.tests: line 28: test: 4+3: integer expected 2 b 4-5 -eq 7 -./test.tests: line 20: [: 4-5: integer expected +./test.tests: line 22: [: 4-5: integer expected 2 t 9 -eq 4+5 -./test.tests: line 26: test: 4+5: integer expected +./test.tests: line 28: test: 4+5: integer expected 2 b 9 -eq 4+5 -./test.tests: line 20: [: 4+5: integer expected +./test.tests: line 22: [: 4+5: integer expected 2 t A -eq 7 -./test.tests: line 26: test: A: integer expected +./test.tests: line 28: test: A: integer expected 2 b A -eq 7 -./test.tests: line 20: [: A: integer expected +./test.tests: line 22: [: A: integer expected 2 t 9 -eq B -./test.tests: line 26: test: B: integer expected +./test.tests: line 28: test: B: integer expected 2 b 9 -eq B -./test.tests: line 20: [: B: integer expected +./test.tests: line 22: [: B: integer expected 2 t ( 1 = 2 -./test.tests: line 26: test: `)' expected +./test.tests: line 28: test: `)' expected 2 b ( 1 = 2 -./test.tests: line 20: [: `)' expected, found ] +./test.tests: line 22: [: `)' expected, found ] 2 -./test.tests: line 26: test: a: unary operator expected +./test.tests: line 28: test: a: unary operator expected 2 -./test.tests: line 26: test: b: binary operator expected +./test.tests: line 28: test: b: binary operator expected 2 -./test.tests: line 26: test: -A: unary operator expected +./test.tests: line 28: test: -A: unary operator expected 2 -./test.tests: line 26: test: syntax error: `-ne' unexpected +./test.tests: line 28: test: syntax error: `-ne' unexpected 2 -./test.tests: line 26: test: too many arguments +./test.tests: line 28: test: too many arguments 2 -./test.tests: line 26: test: syntax error: `-t' unexpected +./test.tests: line 28: test: syntax error: `-t' unexpected 2 -./test.tests: line 26: test: argument expected -2 -./test.tests: line 473: [: missing `]' +./test.tests: line 28: test: argument expected 2 ./test.tests: line 475: [: missing `]' 2 -./test.tests: line 26: test: (: unary operator expected +./test.tests: line 477: [: missing `]' +2 +./test.tests: line 28: test: (: unary operator expected 2 t -t a -./test.tests: line 26: test: a: integer expected +./test.tests: line 28: test: a: integer expected 2 t -t addsds -./test.tests: line 26: test: addsds: integer expected +./test.tests: line 28: test: addsds: integer expected 2 t -t 42 1 t -t /dev/tty -./test.tests: line 26: test: /dev/tty: integer expected +./test.tests: line 28: test: /dev/tty: integer expected 2 t -t /dev/tty4 -./test.tests: line 26: test: /dev/tty4: integer expected +./test.tests: line 28: test: /dev/tty4: integer expected 2 t -t /dev/tty4444444... -./test.tests: line 26: test: /dev/tty4444444...: integer expected +./test.tests: line 28: test: /dev/tty4444444...: integer expected 2 -./test.tests: line 26: test: : integer expected +./test.tests: line 28: test: : integer expected 2 1 0 0 -./test.tests: line 26: test: `)' expected +./test.tests: line 28: test: `)' expected 2 -./test.tests: line 26: test: (: unary operator expected +./test.tests: line 28: test: (: unary operator expected 2 -./test.tests: line 26: test: `)' expected +./test.tests: line 28: test: `)' expected 2 + test1.sub t -p /dev/fd/6 1 t -p /dev/fd/6 diff --git a/tests/test.tests b/tests/test.tests index 412e7834..4f21db51 100644 --- a/tests/test.tests +++ b/tests/test.tests @@ -15,6 +15,8 @@ if (( $UID == 0 )); then echo "test-tests: the test suite should not be run as root" >&2 fi +. ./test-aux-functions + b() { [ "$@" ] @@ -505,4 +507,4 @@ t \( \) t 1 = 1 -a \( \) -a -n "" -${THIS_SH} ./test1.sub +test_runsub ./test1.sub diff --git a/tests/tilde2.right b/tests/tilde2.right index f383e3a3..67d8c7d9 100644 --- a/tests/tilde2.right +++ b/tests/tilde2.right @@ -22,6 +22,7 @@ HOME=~ /usr/$x/abc HOME=/usr/$x/abc /usr/$x/abc + tilde3.sub foo=/home/xyz:/home/xyz /home/xyz:/home/xyz foo=~:~ diff --git a/tests/tilde2.tests b/tests/tilde2.tests index d2415cb3..38a66165 100644 --- a/tests/tilde2.tests +++ b/tests/tilde2.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions + HOME=/usr/xyz XPATH=/bin:/usr/bin:. @@ -82,4 +84,4 @@ eval echo $h eval $h echo $HOME -$THIS_SH ./tilde3.sub +test_runsub ./tilde3.sub diff --git a/tests/trap.right b/tests/trap.right index 83fc3414..05920d51 100644 --- a/tests/trap.right +++ b/tests/trap.right @@ -5,9 +5,9 @@ trap -- 'echo aborting' SIGINT trap -- 'echo aborting' SIGQUIT trap -- 'echo aborting' SIGABRT trap -- 'echo aborting' SIGTERM -[33] debug -debug line [35] debug +debug line +[37] debug trap -- 'echo exiting' EXIT trap -- 'echo aborting' SIGHUP trap -- 'echo aborting' SIGINT @@ -15,10 +15,10 @@ trap -- 'echo aborting' SIGQUIT trap -- 'echo aborting' SIGABRT trap -- 'echo aborting' SIGTERM trap -- 'echo [$LINENO] debug' DEBUG -[37] debug -func[29] funcdebug +[39] debug +func[31] funcdebug funcdebug line -./trap.tests[39] funcdebug +./trap.tests[41] funcdebug trap -- 'echo exiting' EXIT trap -- 'echo aborting' SIGHUP trap -- 'echo aborting' SIGINT @@ -26,14 +26,14 @@ trap -- 'echo aborting' SIGQUIT trap -- 'echo aborting' SIGABRT trap -- 'echo aborting' SIGTERM trap -- 'echo ${FUNCNAME:-$0}[$LINENO] funcdebug' DEBUG -./trap.tests[41] funcdebug -./trap.tests[46] debug -./trap.tests[47] debug -func2[43] debug -func2[44] debug -func2debug line +./trap.tests[43] funcdebug +./trap.tests[48] debug ./trap.tests[49] debug +func2[45] debug +func2[46] debug +func2debug line ./trap.tests[51] debug +./trap.tests[53] debug trap -- 'echo exiting' EXIT trap -- 'echo aborting' SIGHUP trap -- 'echo aborting' SIGINT @@ -53,7 +53,9 @@ trap -- 'echo aborting' SIGQUIT trap -- 'echo aborting' SIGABRT trap -- 'echo aborting' SIGTERM 0 + trap1.sub trap -- '' SIGUSR2 + trap2.sub ERRTRAP ERRTRAP ERRTRAP @@ -72,6 +74,7 @@ ERRTRAP ERRTRAP ERRTRAP ERRTRAP + trap3.sub +[6] echo 1 1 +[7] echo 2 @@ -83,6 +86,7 @@ ERRTRAP trap: 8 +[9] echo 4 4 + trap4.sub exit subshell 1 current shell exit subshell 2 @@ -101,17 +105,21 @@ sleep 2 wait $! exit in trap EXIT + trap6.sub fn after 1 fn after 2 declare -- baz=$'bar\nfoo' + trap7.sub + trap8.sub before after CHLD CHLD CHLD CHLD + trap9.sub BASH_TRAPSIG = USR1 func=7 222 @@ -120,6 +128,7 @@ exit=0 A In trap-argument: last command preceding the trap action In a function call: last command in the trap action + trap10.sub ERR: 23: -func- failed ERR: 20: -[[ -z nonempty ]]- failed ERR: 27: -func- failed @@ -130,10 +139,10 @@ caught a child death caught a child death trap -- 'echo caught a child death' SIGCHLD echo caught a child death -./trap.tests: line 121: trap: cannot specify both -p and -P -./trap.tests: line 122: trap: -P requires at least one signal name +./trap.tests: line 125: trap: cannot specify both -p and -P +./trap.tests: line 126: trap: -P requires at least one signal name trap: usage: trap [-Plp] [[action] signal_spec ...] -./trap.tests: line 124: trap: -x: invalid option +./trap.tests: line 128: trap: -x: invalid option trap: usage: trap [-Plp] [[action] signal_spec ...] trap -- 'echo exiting' EXIT trap -- 'echo aborting' SIGABRT diff --git a/tests/trap.tests b/tests/trap.tests index 6c7706b9..603f5af1 100644 --- a/tests/trap.tests +++ b/tests/trap.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions + # test the trap code trap 'echo exiting' 0 @@ -73,34 +75,36 @@ echo bad echo $? # hmmm...should this set the handling to SIG_IGN for children, too? +printf '\ttrap1.sub\n' trap '' USR2 ./trap1.sub trap - USR2 # test ERR trap +printf '\ttrap2.sub\n' ./trap2.sub -${THIS_SH} ./trap3.sub +test_runsub ./trap3.sub -${THIS_SH} ./trap4.sub +test_runsub ./trap4.sub # This doesn't work right on all Unix versions -#${THIS_SH} ./trap5.sub +#test_runsub ./trap5.sub # Return trap issues -${THIS_SH} ./trap6.sub +test_runsub ./trap6.sub # eval and ERR trap -${THIS_SH} ./trap7.sub +test_runsub ./trap7.sub # SIGCHLD traps -${THIS_SH} ./trap8.sub +test_runsub ./trap8.sub # return without argument in trap string -${THIS_SH} ./trap9.sub +test_runsub ./trap9.sub # ERR trap and functions -${THIS_SH} ./trap10.sub +test_runsub ./trap10.sub # # show that setting a trap on SIGCHLD is not disastrous. diff --git a/tests/type.right b/tests/type.right index 957bc97d..09d01167 100644 --- a/tests/type.right +++ b/tests/type.right @@ -1,7 +1,7 @@ -./type.tests: line 22: type: -r: invalid option +./type.tests: line 24: type: -r: invalid option type: usage: type [-afptP] name [name ...] -./type.tests: line 25: type: notthere: not found -./type.tests: line 29: command: notthere: not found +./type.tests: line 27: type: notthere: not found +./type.tests: line 31: command: notthere: not found function keyword builtin @@ -25,7 +25,7 @@ func () } while while is a shell keyword -./type.tests: line 59: type: morealias: not found +./type.tests: line 61: type: morealias: not found alias morealias='more' alias morealias='more' morealias is aliased to `more' @@ -38,8 +38,8 @@ builtin builtin is a shell builtin /bin/sh /bin/sh is /bin/sh -./type.tests: line 81: type: func: not found -./type.tests: line 83: type: m: not found +./type.tests: line 83: type: func: not found +./type.tests: line 85: type: m: not found /bin/sh /tmp/bash bash is hashed (/tmp/bash) @@ -52,6 +52,7 @@ f () { v='^A' } + type1.sub foo is a function foo () { @@ -62,6 +63,7 @@ bar () { echo $(< x1) } + type2.sub foo is a function foo () { @@ -81,6 +83,7 @@ qux bar qux + type3.sub foo is a function foo () { @@ -97,6 +100,7 @@ EOF a:file b:file c:file + type4.sub bb is a function bb () { @@ -139,6 +143,7 @@ mkcoprocs () { coproc cat -u - & read -u ${COPROC[0]} msg } + type5.sub cat is /bin/cat cat is aliased to `echo cat' /bin/cat diff --git a/tests/type.tests b/tests/type.tests index 48c97d7e..7011e3ed 100644 --- a/tests/type.tests +++ b/tests/type.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions + set +o posix hash -r @@ -104,8 +106,8 @@ f() { type f | cat -v -${THIS_SH} type1.sub -${THIS_SH} type2.sub -${THIS_SH} type3.sub -${THIS_SH} type4.sub -${THIS_SH} type5.sub +test_runsub type1.sub +test_runsub type2.sub +test_runsub type3.sub +test_runsub type4.sub +test_runsub type5.sub diff --git a/tests/varenv.right b/tests/varenv.right index 4ed1e04a..7bb51b6a 100644 --- a/tests/varenv.right +++ b/tests/varenv.right @@ -34,6 +34,7 @@ hBP braceexpand:hashall:interactive-comments:physical declare -r SHELLOPTS="braceexpand:hashall:interactive-comments:physical" abcde + varenv1.sub 20 30 40 @@ -41,6 +42,7 @@ abcde declare -x var="60" outside assignment + varenv2.sub |0|10| 10 |0|10| @@ -54,9 +56,11 @@ after fff3: x=4 |0|12| |y| |y| + varenv3.sub a:b:c:d a-b-c-d a:b:c:d + varenv4.sub g: , f: , FIN: asdf fdsa, asdf fdsa @@ -66,12 +70,15 @@ FIN: v = two, w = one ./varenv4.sub: line 67: bbb: unique: cannot convert indexed to associative array ./varenv4.sub: line 67: declare: unique: cannot convert indexed to associative array after bbb: 1 + varenv5.sub declare -Ar FOOBAR=([foo]="bar" ) declare -Ar FOOBAR=([foo]="bar" ) declare -ar FOOBAR2=([0]="bar") declare -ar FOOBAR2=([0]="bar") + varenv6.sub F OUTSIDE F OUTSIDE + varenv7.sub declare -ar outside=() declare -ir outside1="1" tempenv = foo @@ -87,6 +94,7 @@ outside: outside local: unset1 unset2 abc abc + varenv8.sub :1 :2 after: ---- @@ -95,6 +103,7 @@ global:2 after: --global-- after: ---- x = :1:2 + varenv9.sub in o1 (readonly modifying local scalars): declare -r i1="a b c" declare -r j1="1 2 3" @@ -123,6 +132,7 @@ declare -ar i4=([0]="a" [1]="b" [2]="c") declare -ar j4=([0]="1" [1]="2" [2]="3") ./varenv9.sub: line 79: unset: i4: cannot unset: readonly variable ./varenv9.sub: line 79: unset: j4: cannot unset: readonly variable + varenv10.sub main: unset inner: res unset outer: res: X Y @@ -132,6 +142,7 @@ outer: res: X Y main: after second call: X func: null or unset after func: x = outside + varenv11.sub ./varenv11.sub: line 17: local: qux: readonly variable ./varenv11.sub: line 18: qux: readonly variable ./varenv11.sub: line 18: local: qux: readonly variable @@ -140,6 +151,7 @@ declare -a bar=([0]="zero" [1]="one") declare -A foo=([one]="one" [zero]="zero" ) declare -a bar=([0]="zero" [1]="one") ./varenv11.sub: line 42: a: readonly variable + varenv12.sub foo=abc func1: var = @@ -170,6 +182,7 @@ foo: hello world after foo: var=global bar: hello world after bar: var=global + varenv13.sub ./varenv13.sub: line 16: `var[0]': not a valid identifier ./varenv13.sub: line 16: `var[@]': not a valid identifier ./varenv13.sub: line 14: declare: var: not found @@ -177,6 +190,7 @@ declare -A var=([0]="X" ["@"]="Y" ) help ./varenv13.sub: line 35: `var[0]': not a valid identifier 1 + varenv14.sub declare -A var=([0]="X" ) declare -A var=([Y]="Y" ) declare -A var=([Y]="Y" ) @@ -197,6 +211,7 @@ declare -a v=([0]="7" [1]="1") declare -a array=([0]="1" [1]="2" [2]="3" [3]="list" [4]="of" [5]="four" [6]="words") ./varenv14.sub: line 85: declare: assoc: cannot convert associative to indexed array declare -A assoc=([four]="words" [two]="2" [three]="3" [one]="1" [list]="of" ) + varenv15.sub f: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 f1: after: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 done: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 @@ -227,6 +242,7 @@ after source 1: a b c d e f g h i j k l m n o p q r s t u v w x y z varenv15.in: before set: one two three four five six seven eight nine ten varenv15.in: after set: a b c d e f g h i j k l m n o p q r s t u v w x y z after source 2: a b c d e f g h i j k l m n o p q r s t u v w x y z + varenv16.sub foo=showfoo environment foo=showfoo foo=showfoo environment foo=showfoo foo=showfoo environment foo=showfoo @@ -243,6 +259,7 @@ outside 2.0: foo= foo=foo environment foo=foo foo= environment foo= outside 2.1: foo= + varenv17.sub declare -- var="global" declare -- var declare -- var="local" @@ -256,26 +273,31 @@ declare -- var declare -- var="local" declare -- var="f1" declare -- var="local" + varenv18.sub declare -a arr=([0]="zero" [1]="one" [2]="two" [3]="three" [4]="four" [5]="five") declare -a arr=([0]="zero" [1]="one" [2]="two") declare -a arr=([0]="three" [1]="four" [2]="five") declare -a arr=([0]="zero" [1]="one" [2]="two") + varenv19.sub ddd 0 aaa 1 2 3 bbb 4 5 6 ccc 7 8 9 declare -a x=([0]="one" [1]="two" [2]="three") ./varenv19.sub: line 51: declare: x: not found + varenv20.sub declare -x v="x" declare -x v="t" declare -- v declare -x v + varenv21.sub ignoreeof on ignoreeof off ignoreeof on 10 local - match 1 + varenv22.sub trap -- 'echo trap:$FUNCNAME' EXIT trap:f trap -- 'echo trap:$FUNCNAME' EXIT @@ -284,6 +306,7 @@ trap -- 'echo trap:$FUNCNAME' EXIT trap:f trap -- 'echo trap:$FUNCNAME' EXIT trap:f + varenv23.sub declare -rx x="4" declare -rx y="5" f:3 @@ -310,6 +333,7 @@ f: 3 global: declare -rx c="3" f1: 4 global: declare -- b="8" + varenv24.sub f1: x = local f2: x = local after f2: x = global @@ -328,6 +352,7 @@ after unset f1: x = local f1: x = local after unset f1: x = unset 1009: after posix f1: x = global + varenv25.sub global initial declare -- string declare -i int diff --git a/tests/varenv.tests b/tests/varenv.tests index bdc4f2fe..b622debd 100644 --- a/tests/varenv.tests +++ b/tests/varenv.tests @@ -17,6 +17,8 @@ # Test the behavior of the shell with respect to variable and environment # assignments # +. ./test-aux-functions + expect() { echo expect "$@" @@ -210,59 +212,59 @@ printenv FOOFOO # test out export behavior of variable assignments preceding builtins and # functions -$THIS_SH ./varenv1.sub +test_runsub ./varenv1.sub # more tests; bugs in bash up to version 2.05a -$THIS_SH ./varenv2.sub +test_runsub ./varenv2.sub # more tests; bugs in bash IFS scoping up through version 4.2 -$THIS_SH ./varenv3.sub +test_runsub ./varenv3.sub # scoping problems with declare -g through bash-4.2 -${THIS_SH} ./varenv4.sub +test_runsub ./varenv4.sub # more scoping and declaration problems with -g and arrays through bash-4.2 -${THIS_SH} ./varenv5.sub +test_runsub ./varenv5.sub # variable scoping in the presence of nameref -${THIS_SH} ./varenv6.sub +test_runsub ./varenv6.sub # variable declaration problems with arrays and readonly local variables -${THIS_SH} ./varenv7.sub +test_runsub ./varenv7.sub # variable visibility problems with process substitution subshells in # redirections -${THIS_SH} ./varenv8.sub +test_runsub ./varenv8.sub # make sure that builtins like readonly and export modify local array variables # if executed in shell functions, like they modify local scalar variables -${THIS_SH} ./varenv9.sub +test_runsub ./varenv9.sub # more tests of unset and local variables with dynamic scoping -${THIS_SH} ./varenv10.sub +test_runsub ./varenv10.sub # tests of compound assignments in function scope -${THIS_SH} ./varenv11.sub +test_runsub ./varenv11.sub # temporary environment variable propagation and scoping in posix mode -${THIS_SH} ./varenv12.sub +test_runsub ./varenv12.sub # temporary environment and invalid shell identifier names -${THIS_SH} ./varenv13.sub +test_runsub ./varenv13.sub # localvar_inherit -${THIS_SH} ./varenv14.sub -${THIS_SH} ./varenv15.sub -${THIS_SH} ./varenv16.sub -${THIS_SH} ./varenv17.sub -${THIS_SH} ./varenv18.sub -${THIS_SH} ./varenv19.sub -${THIS_SH} ./varenv20.sub -${THIS_SH} ./varenv21.sub -${THIS_SH} ./varenv22.sub -${THIS_SH} ./varenv23.sub -${THIS_SH} ./varenv24.sub -${THIS_SH} ./varenv25.sub +test_runsub ./varenv14.sub +test_runsub ./varenv15.sub +test_runsub ./varenv16.sub +test_runsub ./varenv17.sub +test_runsub ./varenv18.sub +test_runsub ./varenv19.sub +test_runsub ./varenv20.sub +test_runsub ./varenv21.sub +test_runsub ./varenv22.sub +test_runsub ./varenv23.sub +test_runsub ./varenv24.sub +test_runsub ./varenv25.sub # make sure variable scoping is done right tt() { typeset a=b;echo a=$a; };a=z;echo a=$a;tt;echo a=$a diff --git a/tests/vredir.right b/tests/vredir.right index d0a76a48..5a534d1a 100644 --- a/tests/vredir.right +++ b/tests/vredir.right @@ -8,17 +8,18 @@ bar () exec {v}>> $TMPFILE; echo $v } -./vredir.tests: line 19: v: readonly variable -./vredir.tests: line 19: v: cannot assign fd to variable +./vredir.tests: line 21: v: readonly variable +./vredir.tests: line 21: v: cannot assign fd to variable 42 -./vredir.tests: line 38: v: readonly variable -./vredir.tests: line 38: v: cannot assign fd to variable +./vredir.tests: line 40: v: readonly variable +./vredir.tests: line 40: v: cannot assign fd to variable bar is a function bar () { exec {v}>> $TMPFILE; echo $v } + vredir1.sub 10 line 1 line 2 @@ -49,6 +50,7 @@ EOF echo $v } + vredir2.sub 10 foo 1 foo 2 @@ -76,8 +78,10 @@ iclosev () /bin/sh /bin/tcsh /bin/zsh + vredir3.sub ./vredir3.sub: line 4: v: ambiguous redirect after + vredir4.sub 10 11 a a @@ -92,6 +96,7 @@ swizzle () 10 11 10 11 ./vredir4.sub: line 51: ${output}: Bad file descriptor + vredir5.sub 12 10 a a @@ -103,10 +108,12 @@ swizzle () exec {stdin}<&$fd0-; exec {stdout}>&$fd1- } + vredir6.sub ok 1 ./vredir6.sub: redirection error: cannot duplicate fd: Invalid argument ./vredir6.sub: line 13: /dev/null: Invalid argument unset + vredir7.sub 12 10 a a @@ -118,6 +125,7 @@ swizzle () exec {stdin}<&${fd[0]}-; exec {stdout}>&${fd[1]}- } + vredir8.sub redir 2 ./vredir8.sub: line 33: $fd: Bad file descriptor ./vredir8.sub: line 38: $fd: Bad file descriptor diff --git a/tests/vredir.tests b/tests/vredir.tests index f2c5e4dd..7db313e2 100644 --- a/tests/vredir.tests +++ b/tests/vredir.tests @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +. ./test-aux-functions + : ${TMPDIR:=/var/tmp} TMPFILE=$TMPDIR/foo @@ -46,19 +48,13 @@ rm -f $TMPFILE type bar -${THIS_SH} ./vredir1.sub - -${THIS_SH} ./vredir2.sub - -${THIS_SH} ./vredir3.sub - -${THIS_SH} ./vredir4.sub - -${THIS_SH} ./vredir5.sub - -${THIS_SH} ./vredir6.sub - -${THIS_SH} ./vredir7.sub -${THIS_SH} ./vredir8.sub +test_runsub ./vredir1.sub +test_runsub ./vredir2.sub +test_runsub ./vredir3.sub +test_runsub ./vredir4.sub +test_runsub ./vredir5.sub +test_runsub ./vredir6.sub +test_runsub ./vredir7.sub +test_runsub ./vredir8.sub exit 0