around calls to run_debug_trap the same way we do it for
run_return_trap
Report from Александр Ушаков <anushakov@edu.hse.ru>
+
+ 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 <alexander.bantyev@tweag.io>
+ - keep output of failed tests if the BASH_TSTOUT_SAVEDIR environment
+ variable is set to a valid directory
+ Report and patch from Alexander Bantyev <alexander.bantyev@tweag.io>
+
+ 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
export BASH_TSTOUT=/tmp/xx
rm -f ${BASH_TSTOUT}
+export TAB=' '
+
${THIS_SH} "$@"
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
+ 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 ==
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
+# 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 <http://www.gnu.org/licenses/>.
+#
# test expression evaluation with unset variables
set -u
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
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
0
four - OK
0
+ source7.sub
abc
def
ghi
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
bash: line 1: .: cwd-filename: file not found
file in the current directory
file in the current directory
+ source1.sub
AVAR
foo
foo
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
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")
declare -a c=([0]="1" [1]="2" [2]="3")
unset
unset
+ builtins5.sub
assoc 1 unset
array 1 unset
assoc 2 unset
scalar: 1
scalar: 0
scalar: 0
+ builtins6.sub
all set:
one
two
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
+ 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=
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
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.
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
./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
./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
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+
# tests for miscellaneous builtins not tested elsewhere
set +p
set +o posix
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 "$@"
# 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
# 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
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
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
unset word ok 1
unset word ok 2
unset word ok 3
+ case1.sub
ok 1
ok 2
ok 3
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] = <abc^Adef>
ok 6
ok 7
ok 8
+ case3.sub
--- testing: soh
ok1ok2ok3ok4ok5
ok1ok2ok3ok4ok5
ok1ok2ok3ok4ok5
ok1ok2ok3ok4ok5
ok1ok2ok3ok4ok5
+ case4.sub
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
case foo in
bar) echo skip ;;
foo) echo fallthrough ;&
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
+ 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 `)'
-${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
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 ()
{
));
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 `)'
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
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
: ${HOME:=/}
# works right
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)"
-./comsub.tests: line 19: hijkl: command not found
+./comsub.tests: line 21: hijkl: command not found
argv[1] = <ab>
argv[2] = <cd>
argv[1] = <abmn>
blank ----
blank ----
func: v = comsub
+ comsub1.sub
#esac
a
ok 1
ok 6
xyz
ok 7
+ comsub2.sub
\/tmp\/foo\/bar
/tmp/foo/bar
/tmp/foo/bar
/tmp/foo/bar
+ comsub3.sub
1
2
3
c
1
2
+ comsub4.sub
d \
g
d \
g
d \
g
+ comsub5.sub
ok 1
ok 2
ok 3
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
hey after x
./comsub6.sub: line 40: syntax error near unexpected token `)'
./comsub6.sub: line 40: `math1)'
+ comsub7.sub
123
123
0
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
# command substution parsing tests
TABSIZE=`grep -v '^[ #]' $CAPS </dev/null | grep -v "^$" | grep -v "^capalias"| grep -v "^infoalias" | wc -l`
}
func
-${THIS_SH} ./comsub1.sub
-${THIS_SH} ./comsub2.sub
-${THIS_SH} ./comsub3.sub
-${THIS_SH} ./comsub4.sub
-${THIS_SH} ./comsub5.sub
-${THIS_SH} ./comsub6.sub
-${THIS_SH} ./comsub7.sub
+test_runsub ./comsub1.sub
+test_runsub ./comsub2.sub
+test_runsub ./comsub3.sub
+test_runsub ./comsub4.sub
+test_runsub ./comsub5.sub
+test_runsub ./comsub6.sub
+test_runsub ./comsub7.sub
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
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
42
42
42
+ comsub21.sub
123
123
0
123
before 123
in for 123
+ comsub22.sub
outside before: value
inside before: value
inside after: funsub
outside after: funsub
=====posix mode=====
outside before: value
+ comsub23.sub
.
declare -a a=([0]="1" [1]="2" [2]="3" [3]="4")
declare -- int="2"
after arith for
1) a[${ break;}]
#? after select
+ comsub24.sub
a b c == 1 2 3
== 1 2 3
before return
*???
*???
yyy zzzz
+ comsub25.sub
argv[1] = <AA^ABB>
argv[1] = <AA^OBB>
argv[1] = <AA^?BB>
argv[2] = <BB>
argv[1] = <AA BB>
argv[1] = <AA BB>
+ comsub26.sub
inside1-inside2-outside
BEFOREAA
BB
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-
+. ./test-aux-functions
+#
# initial set of tests for ${Ccommand; } nofork command substitution
# basic functionality
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
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
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
ok c4
ok c5
ok c6
+ cond-regexp1.sub
match 1
match 2
match 3
match control-a 3
match control-a 4
match control-a 5
+ cond-regexp2.sub
ok 1
ok 2
ok 3
ok 10
ok 11
ok 12
+ cond-regexp3.sub
argv[1] = <\^?>
0
1
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 `]]'
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 ]]
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
#
# the test/[ code is tested elsewhere, and the [[...]] just uses the same
# code. this tests the special features of [[...]]
[[ $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
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-
+. ./test-aux-functions
+#
# first, let's start with the basics
recho "$@"
# 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
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
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
ok at 7
ok at 8
ok at 9
+ dollar-at-star3.sub
argv[1] = <a>
argv[1] = <a>
argv[1] = <a>
argv[1] = <one>
<123 abc> <def> <ghi 456>
<123 abc> <def> <ghi\ 456>
+ dollar-at-star4.sub
<c>
a bc
a b
<c>
<d>
<d>
+ dollar-at-star5.sub
0
0
1
variable
argv[1] = <>
dollar-at
+ dollar-at-star6.sub
argv[1] = <'a'>
argv[2] = <'b'>
argv[3] = <'c'>
argv[1] = <'a'>
argv[2] = <'b'>
argv[3] = <'c'>
+ dollar-at-star7.sub
|this|
|is|
|a|
|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] = < >
argv[1] = <^?>
argv[1] = <>
argv[1] = <>
+ dollar-at-star10.sub
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
+ dollar-at-star11.sub
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = </>
1:1
+ dollar-star1.sub
xa|xb|xc
xa|xb|xc
a|b|c
a|b|c
xa|xb|xc
xa|xb|xc
+ dollar-at1.sub
3
3
3
3
3
3
+ dollar-at2.sub
argv[1] = <echo 1 ; echo 1>
argv[1] = <echo 1 2 ; echo 1>
argv[2] = <2>
argv[1] = <echo 1 ; echo 1>
argv[1] = <echo 1 2 ; echo 1>
argv[2] = <2>
+ dollar-star2.sub
argv[1] = <AB>
argv[1] = <AB>
argv[1] = <A BC D>
argv[2] = <C D>
argv[1] = <A BC D>
argv[1] = <A BC D>
+ dollar-star3.sub
argv[1] = <fooq//barq/>
argv[1] = <fooq>
argv[2] = <>
argv[2] = <>
argv[3] = <arq>
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] = <a b>
argv[2] = <c d>
argv[1] = <a>
argv[4] = <d>
argv[1] = <a b c d>
argv[1] = <a b c d>
+ dollar-at5.sub
<1> <2> <3> <4> <5 1>
<1 1> <2> <3> <4> <5>
<11> <2> <3> <4> <51>
set y zcx c2 c3
0
declare -a c=([0]="y" [1]="zcx" [2]="c2" [3]="c3")
+ dollar-at6.sub
argv[1] = <>
argv[2] = <x>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
+ dollar-star6.sub
argv[1] = <AwR>
argv[1] = <AwR>
argv[1] = <AR>
argv[1] = <AwR>
argv[1] = <AwR>
argv[1] = <A^?R>
+ dollar-star7.sub
<a> <b> <ca> <b> <c-a-b-c>
after 1: IFS -
argv[1] = <a-b-c>
argv[3] = <c>
argv[4] = <d>
argv[1] = <a b c d>
+ dollar-star8.sub
<3>
<abc>
<def ghi>
<def>
<ghi>
<jkl>
+ dollar-at7.sub
argv[1] = <1>
argv[2] = <>
argv[1] = <2>
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'>
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
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
./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
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
./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
./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
./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
./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
./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
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
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
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
# These should all be safe
LC_ALL=C
LC_CTYPE=C
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
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
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
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
0
1
0
+ exec7.sub
testb
expand_aliases on
+ exec9.sub
1
1
1
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
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
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
c
d
e
+ exec13.sub
x1
x1a
x2
x3
x3a
x3b
+ exec14.sub
WORKS
done
WORKS
x
y
z
+ exec15.sub
Darwin
x
archive
sub3
1 done
42
+ exec16.sub
test invert
reached subshell
reached group
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
echo "execscript: the test suite should not be run as root" >&2
fi
+. ./test-aux-functions
+
# this should succeed silently
$cmd &
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 | 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` &
# 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
$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
argv[1] = <a>
argv[2] = <b>
argv[3] = <>
+ exp1.sub
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <^?>
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\]
]
hello
eo
+ exp6.sub
argv[1] = <a>
argv[1] = <a>
argv[1] = <^?>
argv[2] = <a>
argv[1] = <correct>
argv[2] = <a>
+ exp7.sub
argv[1] = <^A>
argv[1] = <3>
argv[2] = <^C>
argv[1] = <XY>
argv[2] = <Y>
argv[1] = <XY^AY>
+ exp8.sub
argv[1] = <x^Ay^?z>
argv[1] = <x^Ay^?z>
declare -- var=$'x\001y\177z'
argv[1] = <x^Ay^?z>
declare -a array=([0]=$'x\001y\177z')
declare -A array=([$'x\001y\177z']=$'a\242b\002c' )
+ exp9.sub
abc
def
ghi
[]
[foo]
[]
+ exp10.sub
< A >< B >< A >< B >
< A >< B >< A >< B >
< A >< B >< a >< b >
< A >< B >< a >< b >
< A >< B >< A >< B >
< A >< B ><' A '><' B '>
+ exp11.sub
argv[1] = <1>
argv[2] = <2>
argv[1] = <1>
ok 7
ok 8
ok 9
+ exp12.sub
argv[1] = <file.o>
argv[1] = <posix>
argv[1] = </src/cmd>
abcdefg
abcde
abcdefg
+ exp13.sub
foo
declare -- a="foo"
7
#
# 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
${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
./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
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
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
a b a,b a-b a.b a:b a;b a_b
argv[1] = <ef>
a,b
+ extglob1.sub
a.c
a.c
a.c
ok 1
ok 2
ok 3
+ extglob1a.sub
a ab
a ab
a ab
a
+ extglob3.sub
*(.)
a.log
*(foo)
*(foo|bar).*
a.log
a.log
+ extglob4.sub
.x .y .z
a b c
.x .y .z 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
a .b
.b
.b
+ extglob7.sub
dotglob: .a .foo bar
@(.foo)
.foo
? . .. .a .foo
*
bar
+ extglob8.sub
extglob off
x
extglob off
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
# test the ksh-like extended globbing features: [!@*?+](patlist)
shopt -s extglob
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
{
echo this is zf
}
+ func1.sub
f is a function
f ()
{
} 1>&2;
echo testgrp-b
}
+ func2.sub
funca is a function
funca ()
{
{
:
}
+ func3.sub
expect 5 10
5 10
expect 20
2 40
expect 5 20
5 20
+ func4.sub
./func4.sub: line 23: foo: maximum function nesting level exceeded (100)
1
after: f = 100
./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 ()
{
unset -f $funcs
fi
+. ./test-aux-functions
+
a()
{
x=$((x - 1))
${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() {
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
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 = ?
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
# getopts tests
# this should fail
getopts
# 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
+ glob1.sub
foo/bar foobar/bar
+ glob2.sub
ok 1
ok 2
ok 3
0000004
ok 6
ok 7
+ glob3.sub
invalid bracket expression
== LANG=C ==
[[:alpha:]
ok 3
ok 4
ok 5
+ glob4.sub
argv[1] = <a\?>
a\?
argv[1] = <a\?>
a\a
<define\/\
/>
+ 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
argv[1] = <\$foo>
argv[2] = <\$foo>
argv[1] = <mixed\$foo/>
+ glob6.sub
<abcdefg>
<\.>
*abc.c
searchable/.
searchable/.
searchable/.
+ glob7.sub
1: [qwe/qwe]
2: [qwe/
3: [qwe/]
4:
5: [qwe/
6:
+ glob8.sub
a\*b
a\\ 1*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
argv[3] = <abd>
argv[4] = <abe>
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] = <bdir/>
argv[1] = <*>
argv[1] = <a*>
: # 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
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
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
<a>
<a/a>
<a/a/a>
<b/b/a/a>
<b/b/a/b>
<b/b/b/a>
+ globstar3.sub
a a/aa a/ab b b/bb b/bc c
a/ b/ c/
a/ab b b/bb
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
: ${TMPDIR:=/var/tmp}
dir=$PWD
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
aa=1
}
+ heredoc1.sub
foo is a function
foo ()
{
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')
end hello<NL>\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
argv[1] = <two>
argv[2] = <threefi>
argv[3] = <ve>
+ heredoc5.sub
+ heredoc6.sub
1: OK
2: OK
3: OK
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
./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;
echo 3 4;
done
}
+ heredoc10.sub
hello
world
hello
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
''
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"
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
IFS="/" read -r -d $'\000' -a uu <<< /kghfjk/jkfzuk/i
declare -p uu
+printf '\therestr1.sub\n'
${THIS_SH} ./herestr1.sub
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
3
echo $((1+2))
3
+ histexp1.sub
!
!
!
2 hi 0
!
!
+ histexp2.sub
a
b
c
#!/bin/bash set -o posix
!!
!!
+ histexp3.sub
a
echo $(echo echo a)
echo a
j
echo `echo j` echo j
j echo j
+ histexp4.sub
a
cat < <(echo echo a)
echo a
e
! !
./histexp4.sub: line 33: !': event not found
+ histexp5.sub
/tmp/Step1
echo /$(echo tmp)/Step1
/tmp/Step1
*(/tmp|/dev|/usr)/Step1
echo *(/tmp|/dev|/usr)/Step1
*(/tmp|/dev|/usr)/Step1
+ histexp6.sub
one
echo echo one
echo one
1 echo two
2 for f in a b c; do echo echo two; done
3 history
+ histexp7.sub
a
echo !!
--between--
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
LC_ALL=C
LANG=C
trap 'rm $TMPDIR/newhistory' 0
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
-./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'
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
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
echo cc
cc
1
+ history1.sub
one
two
three
three
(exit 42)
42
+ history2.sub
5.3
echo ${BASH_VERSION%\.*}
5.3
echo ${BASH_VERSION%\.*}
+ history3.sub
a
b
c
./history3.sub: line 48: history: @42: invalid number
./history3.sub: line 49: history: @42: numeric argument required
+ history4.sub
0
1
right)
A
B
+ history5.sub
a
b
./history5.sub: line 24: fc: history specification out of range
6 echo a
7 echo d
8 echo e
+ history6.sub
1
2
3
7 echo 9
8 echo 10
5 echo 10
+ history7.sub
$ 1
$ 2
$ 3
$ 2
$ exit
0
+ history8.sub
a
b
c
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 <<EOF
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
trap 'rm $TMPDIR/newhistory' 0
# bad options
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
a:b:c:d:e
a b c d e
a b c d e
+ ifs1.sub
argv[1] = <file>
argv[1] = <*>
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
OIFS="$IFS"
IFS=":$IFS"
eval foo="a:b:c"
IFS="$DEFIFS"
-${THIS_SH} ./ifs1.sub
+test_runsub ./ifs1.sub
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
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
ಇಳಿಕೆಗಳು
ಇಳ
ಇ
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
-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
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;
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
: ${THIS_SH:=./bash}
{ ${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-$$
argv[1] = <ccc^?ddd>
argv[1] = <eee^?fff>
argv[1] = <ggg^?hhh>
+ iquote1.sub
argv[1] = <xy>
argv[1] = <xy>
argv[1] = <xy>
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./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
recho "eee\7ffff"
recho ggg"$(echo $'\177')"hhh
-${THIS_SH} ./iquote1.sub
+test_runsub ./iquote1.sub
+ 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
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 &
4
0
i killed it
+ jobs5.sub
12
[1]- Running sleep 20 &
[3]+ Running sleep 20 &
./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
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
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 &
[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:
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
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./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 $?
1 -- 0 0 1
1 -- 0 1 0
1 42
+ lastpipe1.sub
lastpipe1.sub returns 14
+ lastpipe2.sub
A1
A2
B1
B1
B2
HI -- 42 -- 0 42
+ lastpipe3.sub
x=x
x=x
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
binfalse()
{
$binfalse || return 1 # normalize return value
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
[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
foo 4 5
+ mapfile2.sub
0 abc
1 def
2 ghi
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
declare -a A
mapfile A < mapfile.data
for (( i = 0 ; i < ${#A[@]} ; i++ )); do
declare -p array
unset -v s array
-${THIS_SH} ./mapfile1.sub
-${THIS_SH} ./mapfile2.sub
+test_runsub ./mapfile1.sub
+test_runsub ./mapfile2.sub
argv[1] = <three four five>
expect <three four five>
argv[1] = <three four five>
-./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 <unset>
argv[1] = <unset>
expect <unset>
three
unset
four
+ nameref4.sub
0
expect <a b>
a b
expect <X>
X
errors = 0
+ nameref5.sub
1
2
v1: 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
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
./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")
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
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
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
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
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
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
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"
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
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
declare -- bar
8
declare -n ivar="foo"
+ nameref20.sub
declare -a v=([0]="Y")
r: <Y>
v: <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"
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]"
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")
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
3
3
5
+ nameref25.sub
bash: line 1: a[k]: unbound variable
ok 1
bash: line 1: r0: unbound variable
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+
# basic nameref tests
bar=one
flow=two
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
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
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
-./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] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = <op>
argv[1] = <abcdefghijklmnop>
argv[1] = <abcdefghijklmnop>
-./new-exp.tests: line 189: bad-var: invalid variable name
+./new-exp.tests: line 191: bad-var: invalid variable name
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
argv[1] = <a>
argv[2] = <b c>
argv[3] = <d>
-./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] = <xxcde>
argv[1] = <axxde>
argv[1] = <abxyz>
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">
argv[7] = <x>
argv[8] = <y>
argv[9] = <z>
-./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] = <a>
argv[2] = <b>
argv[3] = <c>
argv[1] = <a>
argv[2] = <b>
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] = <bin>
argv[2] = <bin>
argv[3] = <ucb>
argv[1] = </>
argv[1] = <full/path/to/x16>
argv[1] = <x16>
+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
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] = <+^?>
argv[1] = <>
argv[1] = <>
argv[1] = </tmp/test/TEST>
+ new-exp7.sub
foo is a function
foo ()
{
{
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
c Sub = 0 2 4 8
<1> <2> <3> <4> <5>
<10> <20> <40> <80>
+ new-exp10.sub
<>
<>
<>
argv[1] = </ bash$ >
argv[1] = <1^J/ bash$ >
./new-exp10.sub: line 153: ${V@}: bad substitution
+ new-exp11.sub
abcxxxdef
abcådef
ḅć
Ã¥
ḅć
ḅć
+ new-exp12.sub
HELLO;1 foo;2 foo;
PASS;1 foo;2 foo;
after: PASS
+ new-exp13.sub
'zzz'
'zzz'
declare -rl VAR1
'aaa' 'bbb'
a bbb
aaa bb
+ new-exp14.sub
'string'
'string'
'value with spaces'
argv[6] = <two t>
argv[7] = <3>
argv[8] = <three t>
+ new-exp15.sub
declare -a foo=()
ai
declare -ai foo
a
a
a
+ new-exp16.sub
/homes/chetdefg
/homes/chetdefg
~defg
&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
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
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 $(<filename) in a subshell to avoid cluttering up
-# this script
-${THIS_SH} ./new-exp2.sub
-
expect '<6>'
recho ${#:-foo}
expect $0: '${#:}: bad substitution'
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/}
recho ${1#*/}
recho ${1##*/}
-${THIS_SH} ./new-exp5.sub
-
unset var
var=blah
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
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 $(<filename) in a subshell to avoid cluttering up
+# this script
+test_runsub ./new-exp2.sub
+
+# tests of new prefix expansion ${!prefix*}
+test_runsub ./new-exp3.sub
+
+# bug with indirect expansion through bash-2.05b
+test_runsub ./new-exp4.sub
+
+test_runsub ./new-exp5.sub
+
+test_runsub ./new-exp6.sub
+
+test_runsub ./new-exp7.sub
+
+test_runsub ./new-exp8.sub
+
+# tests to check whether things like indirect expansion of a variable whose
+# value is 'anothervar[@]' stop working
+test_runsub ./new-exp9.sub
+
+# new parameter transformation `@' expansion operator
+test_runsub ./new-exp10.sub
+
+# parameter substring replacement and removal operators with multibyte chars
+test_runsub ./new-exp11.sub
+
+# indirect expansion with arrays and local variables
+test_runsub ./new-exp12.sub
+
+# more indirect expansion and parameter transformation issues
+test_runsub ./new-exp13.sub
+
+# new K parameter transformation operator
+test_runsub ./new-exp14.sub
+
+# ongoing work with a/A parameter transformations and `nounset'
+test_runsub ./new-exp15.sub
+
+# pattern substitution with `&' (quoted and unquoted) in the replacement string
+test_runsub ./new-exp16.sub
+
expect $0: 'ABXD: parameter unset'
${THIS_SH} -c 'recho ${ABXD:?"parameter unset"}' $0
argv[1] = <$'a\tb\tc'>
AD
E
+ nquote1.sub
hello' world
hello world!
hello' world!
+ nquote2.sub
' | '
' | '
x | x
$'\'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] = <a^A)b>
argv[1] = <a^Ab>
argv[1] = <^A>
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
expect()
{
echo expect "$@"
# 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
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
# 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
${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
argv[1] = <foo 'bar baz>
argv[1] = <}z>
argv[1] = <''z}>
+ posixexp1.sub
+ posixexp1.sub
+ posixexp2.sub
+ posixexp3.sub
argv[1] = <1>
argv[2] = <2>
argv[1] = <1>
argv[1] = <1 2>
argv[1] = <12>
argv[1] = <12>
+ posixexp4.sub
normal IFS
argv[1] = <abc>
argv[2] = <def>
argv[3] = <jkl >
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
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^?>
[ 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
./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] = <A>
argv[1] = <A>
-./posixexp.tests: line 97: unexpected EOF while looking for matching `}'
+./posixexp.tests: line 101: unexpected EOF while looking for matching `}'
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
unset a
printf "%s\n" ${a:=a\ b}
echo "$a"
: ${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
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
--\"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--
----
----
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 )
''
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
^G
^Ge
"?
+ printf2.sub
+ printf3.sub
16:09:15
./printf3.sub: line 27: printf: warning: `Z': invalid time format specification
%(abde)Z
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
x +123x
x +123x
x +123x
+ printf5.sub
abcd
ab
123
hello --
123 --
6 --
+ printf6.sub
0000000 000
0000001
0000000 000
0000000 340 262 207 040 040 040 055 055 055 012
000000a
[][]
+ printf7.sub
[]
[X]
VAR=[]
: ${TMPDIR:=/tmp}
TMPF=$TMPDIR/printf-oflow-$RANDOM
+. ./test-aux-functions
+
printf_overflow ()
{
local r;
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
0
0
0
+ procsub1.sub
123
+ procsub2.sub
bar1
ouch
bar2
unset -f moo
-${THIS_SH} ./procsub1.sub
-${THIS_SH} ./procsub2.sub
+test_runsub ./procsub1.sub
+test_runsub ./procsub2.sub
string \}
escape\
escape\
+ quote1.sub
'weferfds'\''dsfsdf'
'weferfdsdsfsdf'
'weferfds'\''dsfsdf'
a'b'c
foo b c baz
foo 'bar baz
+ quote2.sub
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[2] = <>
argv[1] = <>
+ quote3.sub
argv[1] = <4>
argv[2] = <>
argv[1] = <ab>
argv[1] = <ab >
argv[1] = <ab ''>
argv[1] = <ab >
+ quote4.sub
0
1
1
: ${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
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
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
[[ -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
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" )
declare -A map=()
$(DOESNOTEXIST)
declare -A blah=()
+ quotearray4.sub
declare -A assoc=(["*"]="star" ["!"]="bang" ["@"]="at" )
declare -A assoc=(["*"]="star" ["!"]="bang" )
declare -A assoc=(["!"]="bang" )
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=()
#
# a set of tests for associative arrays in arithmetic contexts
+. ./test-aux-functions
declare -A assoc
key='x],b[$(echo uname >&2)'
(( 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
argv[1] = <foo>
argv[1] = <foo>
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
<$'spring\375'>
<summer>
<automn>
+ read2.sub
timeout 1: ok
unset or null 1
timeout 2: ok
abcde
abcde
abcde
+ read3.sub
./read3.sub: line 17: read: -1: invalid number
abc
defg
abc
#
0
+ read4.sub
while read -u 3 var
do
echo "$var"
done 3<$0
+ read5.sub
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[3] = <>
FOO
0 0 0
+ read6.sub
0
0
1
+ read7.sub
timeout 1: ok
unset or null 1
timeout 2: 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 ]
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
echo " a " | (read x; echo "$x.")
echo " a b " | ( read x y ; echo -"$x"-"$y"- )
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
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
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
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
}
after read
# This program is free software: you can redistribute it and/or modify
+ redir6.sub
/
/
/
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
4
cat /tmp/foo
whatsis
+ redir9.sub
hey
to stdout
to stderr
foo
foo
foo
+ redir10.sub
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ redir11.sub
1
7
after: 42
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
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
: ${TMPDIR:=/tmp}
+. ./test-aux-functions
export LC_ALL=C
export LANG=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()
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}
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-$$
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
ab
a/b
ab
+ rhs-exp1.sub
argv[1] = <bc>
argv[1] = <bc>
argv[1] = <ab>
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+#
selvecs='&m68kcoff_vec'
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'$selvecs\'}"
var="a/b" ; echo "${var//\\//}"
var="a/b" ; echo "${var//\//}"
-${THIS_SH} ./rhs-exp1.sub
+test_runsub ./rhs-exp1.sub
+ 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
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# 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
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
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}
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}
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}
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}
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}
-
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
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
#
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}
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 -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}
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}
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}
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}
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}
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}
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}
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}
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}
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}
# 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}
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}
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}
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}
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}
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}
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}
after 1
a
0
+ set-e1.sub
non-posix foo
after brace group failure: 1
A 1
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
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+
if : ; then
set -e
N=95
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
+ echo onetwo
onetwo
+ set +x
+ set-x1.sub
./set-x1.sub: line 18: BASH_XTRACEFD: 4: invalid value for trace file descriptor
1
2
+ echo 4
+ unset BASH_XTRACEFD
=====
+ set-x2.sub
+ metas=(\| \& \; \( \) \< \> ' ' ' ' '
')
+ n=($@)
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
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
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
echo "test-tests: the test suite should not be run as root" >&2
fi
+. ./test-aux-functions
+
b()
{
[ "$@" ]
t 1 = 1 -a \( \) -a -n ""
-${THIS_SH} ./test1.sub
+test_runsub ./test1.sub
/usr/$x/abc
HOME=/usr/$x/abc
/usr/$x/abc
+ tilde3.sub
foo=/home/xyz:/home/xyz
/home/xyz:/home/xyz
foo=~:~
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+
HOME=/usr/xyz
XPATH=/bin:/usr/bin:.
eval $h
echo $HOME
-$THIS_SH ./tilde3.sub
+test_runsub ./tilde3.sub
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
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
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
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
0
+ trap1.sub
trap -- '' SIGUSR2
+ trap2.sub
ERRTRAP
ERRTRAP
ERRTRAP
ERRTRAP
ERRTRAP
ERRTRAP
+ trap3.sub
+[6] echo 1
1
+[7] echo 2
trap: 8
+[9] echo 4
4
+ trap4.sub
exit subshell 1
current shell
exit subshell 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
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
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
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+
# test the trap code
trap 'echo exiting' 0
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.
-./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
}
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'
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)
{
v='^A'
}
+ type1.sub
foo is a function
foo ()
{
{
echo $(< x1)
}
+ type2.sub
foo is a function
foo ()
{
bar
qux
+ type3.sub
foo is a function
foo ()
{
a:file
b:file
c:file
+ type4.sub
bb is a function
bb ()
{
{
coproc cat -u - & read -u ${COPROC[0]} msg
}
+ type5.sub
cat is /bin/cat
cat is aliased to `echo cat'
/bin/cat
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+
set +o posix
hash -r
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
braceexpand:hashall:interactive-comments:physical
declare -r SHELLOPTS="braceexpand:hashall:interactive-comments:physical"
abcde
+ varenv1.sub
20
30
40
declare -x var="60"
outside
assignment
+ varenv2.sub
|0|10|
10
|0|10|
|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
./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
local: unset1 unset2
abc
abc
+ varenv8.sub
:1
:2
after: ----
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"
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
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
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 =
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
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" )
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
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
foo=foo environment foo=foo
foo=<unset> environment foo=
outside 2.1: foo=<unset>
+ varenv17.sub
declare -- var="global"
declare -- var
declare -- var="local"
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
trap:f
trap -- 'echo trap:$FUNCNAME' EXIT
trap:f
+ varenv23.sub
declare -rx x="4"
declare -rx y="5"
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
f1: x = local
after unset f1: x = unset
1009: after posix f1: x = global
+ varenv25.sub
global initial
declare -- string
declare -i int
# Test the behavior of the shell with respect to variable and environment
# assignments
#
+. ./test-aux-functions
+
expect()
{
echo expect "$@"
# 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
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
echo $v
}
+ vredir2.sub
10
foo 1
foo 2
/bin/sh
/bin/tcsh
/bin/zsh
+ vredir3.sub
./vredir3.sub: line 4: v: ambiguous redirect
after
+ vredir4.sub
10 11
a
a
10 11
10 11
./vredir4.sub: line 51: ${output}: Bad file descriptor
+ vredir5.sub
12 10
a
a
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
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
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+. ./test-aux-functions
+
: ${TMPDIR:=/var/tmp}
TMPFILE=$TMPDIR/foo
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