summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2020-12-06 15:51:17 -0500
committerChet Ramey <chet.ramey@case.edu>2020-12-06 15:51:17 -0500
commit8868edaf2250e09c4e9a1c75ffe3274f28f38581 (patch)
treed9a7812ab6cd2f45c5021755c4c094b19dab1b51 /tests
parent36f2c406ff27995392a9247dfa90672fdaf7dc43 (diff)
downloadbash-8868edaf2250e09c4e9a1c75ffe3274f28f38581.tar.gz
bash-5.1 distribution sources and documentationbash-5.1
Diffstat (limited to 'tests')
-rw-r--r--tests/alias.right12
-rw-r--r--tests/alias.tests14
-rw-r--r--tests/alias1.sub13
-rw-r--r--tests/alias2.sub13
-rw-r--r--tests/alias3.sub1
-rw-r--r--tests/alias4.sub30
-rw-r--r--tests/alias5.sub28
-rw-r--r--tests/appendop.right6
-rw-r--r--tests/appendop.tests13
-rw-r--r--tests/appendop1.sub13
-rw-r--r--tests/appendop2.sub13
-rw-r--r--tests/arith-for.right8
-rw-r--r--tests/arith-for.tests13
-rw-r--r--tests/arith.right70
-rw-r--r--tests/arith.tests15
-rw-r--r--tests/arith1.sub13
-rw-r--r--tests/arith2.sub13
-rw-r--r--tests/arith3.sub27
-rw-r--r--tests/arith5.sub16
-rw-r--r--tests/arith6.sub13
-rw-r--r--tests/arith8.sub13
-rw-r--r--tests/array.right117
-rw-r--r--tests/array.tests23
-rw-r--r--tests/array10.sub13
-rw-r--r--tests/array11.sub13
-rw-r--r--tests/array12.sub13
-rw-r--r--tests/array13.sub1
-rw-r--r--tests/array14.sub13
-rw-r--r--tests/array15.sub13
-rw-r--r--tests/array16.sub13
-rw-r--r--tests/array17.sub13
-rw-r--r--tests/array18.sub13
-rw-r--r--tests/array19.sub18
-rw-r--r--tests/array20.sub13
-rw-r--r--tests/array21.sub13
-rw-r--r--tests/array22.sub13
-rw-r--r--tests/array23.sub13
-rw-r--r--tests/array24.sub13
-rw-r--r--tests/array25.sub13
-rw-r--r--tests/array26.sub13
-rw-r--r--tests/array27.sub13
-rw-r--r--tests/array28.sub30
-rw-r--r--tests/array4.sub13
-rw-r--r--tests/array5.sub13
-rw-r--r--tests/array6.sub13
-rw-r--r--tests/array8.sub13
-rw-r--r--tests/array9.sub13
-rw-r--r--tests/assoc.right127
-rw-r--r--tests/assoc.tests27
-rw-r--r--tests/assoc1.sub13
-rw-r--r--tests/assoc10.sub13
-rw-r--r--tests/assoc11.sub90
-rw-r--r--tests/assoc2.sub13
-rw-r--r--tests/assoc3.sub13
-rw-r--r--tests/assoc4.sub13
-rw-r--r--tests/assoc5.sub13
-rw-r--r--tests/assoc6.sub13
-rw-r--r--tests/assoc7.sub13
-rw-r--r--tests/assoc9.sub20
-rw-r--r--tests/attr.right16
-rw-r--r--tests/attr.tests13
-rw-r--r--tests/attr1.sub13
-rw-r--r--tests/attr2.sub13
-rw-r--r--tests/braces.tests13
-rw-r--r--tests/builtins.right50
-rw-r--r--tests/builtins.tests20
-rw-r--r--tests/builtins4.sub13
-rw-r--r--tests/builtins5.sub13
-rw-r--r--tests/builtins6.sub13
-rw-r--r--tests/builtins7.sub38
-rw-r--r--tests/case.right2
-rw-r--r--tests/case.tests13
-rw-r--r--tests/case1.sub13
-rw-r--r--tests/case2.sub13
-rw-r--r--tests/case3.sub14
-rw-r--r--tests/case4.sub13
-rw-r--r--tests/casemod.right2
-rw-r--r--tests/casemod.tests17
-rw-r--r--tests/complete.right63
-rw-r--r--tests/complete.tests126
-rw-r--r--tests/comsub-eof.right2
-rw-r--r--tests/comsub-eof.tests2
-rw-r--r--tests/comsub-eof6.sub5
-rw-r--r--tests/comsub-posix.right4
-rw-r--r--tests/comsub-posix.tests28
-rw-r--r--tests/comsub-posix2.sub13
-rw-r--r--tests/comsub-posix3.sub13
-rw-r--r--tests/comsub.right2
-rw-r--r--tests/comsub.tests13
-rw-r--r--tests/comsub1.sub13
-rw-r--r--tests/comsub3.sub13
-rw-r--r--tests/comsub4.sub13
-rw-r--r--tests/cond-regexp1.sub13
-rw-r--r--tests/cond-regexp2.sub13
-rw-r--r--tests/cond-regexp3.sub13
-rw-r--r--tests/cond.right2
-rw-r--r--[-rwxr-xr-x]tests/cond.tests13
-rw-r--r--tests/coproc.tests13
-rw-r--r--tests/cprint.tests13
-rw-r--r--tests/dbg-support.right614
-rw-r--r--tests/dbg-support.sub13
-rw-r--r--[-rwxr-xr-x]tests/dbg-support.tests24
-rw-r--r--tests/dbg-support2.right10
-rw-r--r--[-rwxr-xr-x]tests/dbg-support2.tests19
-rw-r--r--tests/dbg-support3.sub13
-rwxr-xr-xtests/dollar-at-star8
-rw-r--r--tests/dollar-at-star1.sub13
-rw-r--r--tests/dollar-at-star2.sub13
-rw-r--r--tests/dollar-at-star3.sub13
-rw-r--r--tests/dollar-at-star4.sub13
-rw-r--r--tests/dollar-at-star5.sub13
-rw-r--r--tests/dollar-at-star6.sub13
-rw-r--r--tests/dollar-at-star7.sub13
-rw-r--r--tests/dollar-at-star9.sub278
-rw-r--r--tests/dollar-at1.sub13
-rw-r--r--tests/dollar-at2.sub13
-rw-r--r--tests/dollar-at5.sub13
-rw-r--r--tests/dollar-at6.sub13
-rw-r--r--tests/dollar-at7.sub13
-rw-r--r--tests/dollar-star1.sub13
-rw-r--r--tests/dollar-star10.sub92
-rw-r--r--tests/dollar-star2.sub13
-rw-r--r--tests/dollar-star3.sub13
-rw-r--r--tests/dollar-star5.sub13
-rw-r--r--tests/dollar-star6.sub13
-rw-r--r--tests/dollar-star7.sub13
-rw-r--r--tests/dollar-star8.sub13
-rw-r--r--tests/dollar-star9.sub13
-rw-r--r--tests/dollar.right98
-rw-r--r--tests/dstack.right26
-rw-r--r--tests/dstack.tests15
-rw-r--r--tests/dstack2.tests13
-rw-r--r--tests/dynvar.tests15
-rw-r--r--tests/errors.right256
-rw-r--r--tests/errors.tests18
-rw-r--r--tests/errors1.sub13
-rw-r--r--tests/errors4.sub13
-rw-r--r--tests/errors6.sub13
-rw-r--r--tests/errors7.sub13
-rw-r--r--tests/exec.right28
-rw-r--r--tests/exec10.sub13
-rw-r--r--tests/exec12.sub13
-rw-r--r--tests/exec13.sub13
-rw-r--r--tests/exec14.sub47
-rw-r--r--tests/exec6.sub13
-rw-r--r--tests/exec7.sub13
-rw-r--r--tests/exec9.sub13
-rw-r--r--tests/execscript1
-rw-r--r--tests/exp.right5
-rw-r--r--tests/exp.tests15
-rw-r--r--tests/exp1.sub13
-rw-r--r--tests/exp10.sub13
-rw-r--r--tests/exp11.sub13
-rw-r--r--tests/exp12.sub13
-rw-r--r--tests/exp5.sub13
-rw-r--r--tests/exp6.sub13
-rw-r--r--tests/exp7.sub13
-rw-r--r--tests/exp8.sub13
-rw-r--r--tests/exp9.sub13
-rw-r--r--tests/exportfunc.right14
-rw-r--r--tests/exportfunc.tests13
-rw-r--r--tests/exportfunc1.sub13
-rw-r--r--tests/exportfunc2.sub13
-rw-r--r--tests/exportfunc3.sub13
-rw-r--r--tests/extglob.tests13
-rw-r--r--tests/extglob1.sub13
-rw-r--r--tests/extglob1a.sub13
-rw-r--r--[-rwxr-xr-x]tests/extglob2.tests13
-rw-r--r--tests/extglob3.sub13
-rw-r--r--tests/extglob3.tests13
-rw-r--r--tests/extglob4.sub13
-rw-r--r--tests/extglob5.sub13
-rw-r--r--tests/func.right10
-rw-r--r--tests/func.tests13
-rw-r--r--tests/func1.sub13
-rw-r--r--tests/func2.sub13
-rw-r--r--tests/func3.sub15
-rw-r--r--tests/func4.sub13
-rw-r--r--tests/getopts.right12
-rw-r--r--tests/getopts.tests13
-rw-r--r--tests/getopts1.sub13
-rw-r--r--tests/getopts10.sub13
-rw-r--r--tests/getopts2.sub13
-rw-r--r--tests/getopts3.sub13
-rw-r--r--tests/getopts4.sub13
-rw-r--r--tests/getopts5.sub13
-rw-r--r--tests/getopts6.sub13
-rw-r--r--tests/getopts7.sub13
-rw-r--r--tests/getopts9.sub13
-rw-r--r--tests/glob.right68
-rw-r--r--tests/glob.tests18
-rw-r--r--tests/glob1.sub13
-rw-r--r--tests/glob2.sub13
-rw-r--r--tests/glob3.sub48
-rw-r--r--tests/glob4.sub30
-rw-r--r--tests/glob5.sub76
-rw-r--r--tests/glob6.sub68
-rw-r--r--tests/glob7.sub11
-rw-r--r--tests/glob8.sub31
-rw-r--r--tests/glob9.sub13
-rw-r--r--tests/globstar.right3
-rw-r--r--tests/globstar.tests14
-rw-r--r--tests/globstar1.sub13
-rw-r--r--tests/globstar2.sub13
-rw-r--r--tests/globstar3.sub37
-rw-r--r--tests/heredoc.right22
-rw-r--r--tests/heredoc.tests46
-rw-r--r--tests/heredoc1.sub13
-rw-r--r--tests/heredoc3.sub13
-rw-r--r--tests/heredoc5.sub41
-rw-r--r--tests/herestr.right7
-rw-r--r--tests/herestr.tests33
-rw-r--r--tests/histexp.right8
-rw-r--r--tests/histexp.tests14
-rw-r--r--tests/histexp1.sub13
-rw-r--r--tests/histexp3.sub13
-rw-r--r--tests/histexp4.sub13
-rw-r--r--tests/histexp5.sub13
-rw-r--r--tests/histexp6.sub13
-rw-r--r--tests/histexp7.sub18
-rw-r--r--tests/history.right112
-rw-r--r--tests/history.tests16
-rw-r--r--tests/history1.sub13
-rw-r--r--tests/history3.sub13
-rw-r--r--tests/history4.sub47
-rw-r--r--tests/history5.sub57
-rw-r--r--tests/ifs-posix.tests13
-rw-r--r--tests/ifs.tests13
-rw-r--r--tests/intl.tests13
-rw-r--r--tests/intl3.sub13
-rw-r--r--tests/invert.tests13
-rw-r--r--tests/iquote.tests13
-rw-r--r--tests/iquote1.sub13
-rw-r--r--tests/jobs.right49
-rw-r--r--tests/jobs.tests52
-rw-r--r--tests/jobs1.sub13
-rw-r--r--tests/jobs3.sub15
-rw-r--r--tests/jobs4.sub13
-rw-r--r--tests/jobs5.sub51
-rw-r--r--tests/jobs7.sub6
-rw-r--r--tests/lastpipe.tests16
-rw-r--r--tests/lastpipe2.sub13
-rw-r--r--tests/mapfile.tests13
-rw-r--r--tests/more-exp.right16
-rw-r--r--tests/more-exp.tests13
-rw-r--r--tests/nameref.right294
-rw-r--r--tests/nameref.tests13
-rw-r--r--tests/nameref10.sub13
-rw-r--r--tests/nameref11.sub13
-rw-r--r--tests/nameref12.sub13
-rw-r--r--tests/nameref13.sub13
-rw-r--r--tests/nameref14.sub13
-rw-r--r--tests/nameref15.sub13
-rw-r--r--tests/nameref16.sub13
-rw-r--r--tests/nameref17.sub13
-rw-r--r--tests/nameref18.sub13
-rw-r--r--tests/nameref19.sub13
-rw-r--r--tests/nameref20.sub13
-rw-r--r--tests/nameref21.sub13
-rw-r--r--tests/nameref3.sub13
-rw-r--r--tests/nameref4.sub13
-rw-r--r--tests/nameref5.sub13
-rw-r--r--tests/nameref6.sub13
-rw-r--r--tests/nameref7.sub13
-rw-r--r--tests/nameref8.sub13
-rw-r--r--tests/new-exp.right97
-rw-r--r--tests/new-exp.tests39
-rw-r--r--tests/new-exp1.sub13
-rw-r--r--tests/new-exp10.sub13
-rw-r--r--tests/new-exp11.sub13
-rw-r--r--tests/new-exp12.sub40
-rw-r--r--tests/new-exp13.sub72
-rw-r--r--tests/new-exp14.sub19
-rw-r--r--tests/new-exp15.sub29
-rw-r--r--tests/new-exp2.sub15
-rw-r--r--tests/new-exp3.sub13
-rw-r--r--tests/new-exp4.sub14
-rw-r--r--tests/new-exp5.sub13
-rw-r--r--tests/new-exp6.sub13
-rw-r--r--tests/new-exp8.sub13
-rw-r--r--tests/new-exp9.sub13
-rw-r--r--tests/nquote.tests13
-rw-r--r--tests/nquote1.tests13
-rw-r--r--tests/nquote2.sub13
-rw-r--r--tests/nquote2.tests13
-rw-r--r--tests/nquote3.tests13
-rw-r--r--tests/nquote4.tests13
-rw-r--r--tests/nquote5.tests13
-rw-r--r--tests/parser.right14
-rw-r--r--tests/posix2.right8
-rw-r--r--tests/posix2.tests15
-rw-r--r--tests/posix2syntax.sub13
-rw-r--r--tests/posixexp.right9
-rw-r--r--tests/posixexp.tests14
-rw-r--r--tests/posixexp1.sub13
-rw-r--r--tests/posixexp2.sub13
-rw-r--r--tests/posixexp2.tests13
-rw-r--r--tests/posixexp3.sub13
-rw-r--r--tests/posixexp4.sub13
-rw-r--r--tests/posixexp5.sub13
-rw-r--r--tests/posixexp6.sub13
-rw-r--r--tests/posixexp8.sub11
-rw-r--r--tests/posixpat.tests13
-rw-r--r--tests/posixpipe.tests13
-rwxr-xr-xtests/precedence.tests90
-rw-r--r--tests/printf.right26
-rw-r--r--tests/printf.tests13
-rw-r--r--tests/printf1.sub13
-rw-r--r--tests/printf3.sub13
-rw-r--r--tests/printf4.sub13
-rw-r--r--tests/procsub.right6
-rw-r--r--tests/procsub.tests28
-rw-r--r--tests/procsub2.sub36
-rw-r--r--tests/quote.right64
-rw-r--r--tests/quote.tests15
-rw-r--r--tests/quote1.sub13
-rw-r--r--tests/quote2.sub13
-rw-r--r--tests/quote3.sub31
-rw-r--r--tests/quote4.sub101
-rw-r--r--tests/read.right4
-rw-r--r--tests/read.tests13
-rw-r--r--tests/read1.sub13
-rw-r--r--tests/read2.sub13
-rw-r--r--tests/read3.sub13
-rw-r--r--tests/read5.sub13
-rw-r--r--tests/redir.right29
-rw-r--r--tests/redir.tests13
-rw-r--r--tests/redir10.sub14
-rw-r--r--tests/redir11.sub22
-rw-r--r--tests/redir3.sub13
-rw-r--r--tests/redir4.sub13
-rw-r--r--tests/redir5.sub13
-rw-r--r--tests/redir7.sub13
-rw-r--r--tests/redir8.sub13
-rw-r--r--tests/redir9.sub13
-rw-r--r--tests/rhs-exp.tests13
-rw-r--r--tests/rhs-exp1.sub13
-rw-r--r--tests/rsh.right34
-rw-r--r--tests/rsh.tests13
-rw-r--r--tests/rsh1.sub13
-rw-r--r--tests/rsh2.sub13
-rw-r--r--tests/run-all18
-rw-r--r--tests/run-complete2
-rw-r--r--tests/run-dbg-support2
-rw-r--r--tests/run-dbg-support27
-rw-r--r--tests/run-minimal17
-rw-r--r--tests/run-precedence2
-rw-r--r--tests/run-varenv2
-rw-r--r--tests/run-vredir2
-rw-r--r--tests/set-e.tests13
-rw-r--r--tests/set-e1.sub13
-rw-r--r--[-rwxr-xr-x]tests/set-x.tests15
-rw-r--r--tests/set-x1.sub13
-rw-r--r--tests/shopt.right8
-rw-r--r--tests/shopt.tests19
-rw-r--r--tests/shopt1.sub52
-rw-r--r--tests/source5.sub15
-rw-r--r--tests/source6.sub13
-rw-r--r--tests/source7.sub13
-rw-r--r--tests/strip.tests13
-rw-r--r--tests/test.right34
-rw-r--r--tests/test.tests15
-rw-r--r--tests/test1.sub13
-rw-r--r--tests/tilde.right2
-rw-r--r--tests/tilde.tests17
-rw-r--r--tests/tilde2.tests13
-rw-r--r--tests/trap.right28
-rw-r--r--tests/trap.tests13
-rwxr-xr-xtests/trap2.sub13
-rw-r--r--tests/trap3.sub2
-rw-r--r--tests/trap4.sub13
-rw-r--r--tests/trap5.sub13
-rw-r--r--tests/trap6.sub13
-rw-r--r--tests/type.right12
-rw-r--r--tests/type.tests13
-rw-r--r--tests/type2.sub13
-rw-r--r--tests/type3.sub13
-rw-r--r--tests/type4.sub13
-rw-r--r--tests/unicode1.sub13
-rw-r--r--tests/unicode2.sub13
-rw-r--r--tests/varenv.right130
-rw-r--r--tests/varenv.tests22
-rw-r--r--tests/varenv1.sub13
-rw-r--r--tests/varenv10.sub16
-rw-r--r--tests/varenv11.sub13
-rw-r--r--tests/varenv12.sub105
-rw-r--r--tests/varenv13.sub13
-rw-r--r--tests/varenv14.sub15
-rw-r--r--tests/varenv15.sub13
-rw-r--r--tests/varenv16.sub51
-rw-r--r--tests/varenv17.sub44
-rw-r--r--tests/varenv18.sub41
-rw-r--r--tests/varenv19.sub51
-rw-r--r--tests/varenv2.sub13
-rw-r--r--tests/varenv20.sub13
-rw-r--r--tests/varenv21.sub48
-rw-r--r--tests/varenv3.sub14
-rw-r--r--tests/varenv4.sub13
-rw-r--r--tests/varenv5.sub13
-rw-r--r--tests/varenv6.sub13
-rw-r--r--tests/varenv7.sub13
-rw-r--r--tests/varenv9.sub13
-rw-r--r--tests/vredir.right4
-rw-r--r--tests/vredir.tests13
-rw-r--r--tests/vredir1.sub13
-rw-r--r--tests/vredir2.sub13
-rw-r--r--tests/vredir4.sub13
-rw-r--r--tests/vredir5.sub13
-rw-r--r--tests/vredir7.sub13
409 files changed, 7978 insertions, 1114 deletions
diff --git a/tests/alias.right b/tests/alias.right
index 3ab9a717..9e33036b 100644
--- a/tests/alias.right
+++ b/tests/alias.right
@@ -1,6 +1,6 @@
alias: 0
alias: 0
-./alias.tests: line 25: qfoo: command not found
+./alias.tests: line 38: qfoo: command not found
quux
bar
value
@@ -30,3 +30,13 @@ a b
a a b
ok 3
ok 4
+bar
+bad
+0
+<|cat>
+foo
+bar
+baz
+foo
+bar
+baz
diff --git a/tests/alias.tests b/tests/alias.tests
index 6aa1218b..0280c16d 100644
--- a/tests/alias.tests
+++ b/tests/alias.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# place holder for future alias testing
shopt -s expand_aliases
@@ -40,3 +53,4 @@ ${THIS_SH} ./alias1.sub
${THIS_SH} ./alias2.sub
${THIS_SH} ./alias3.sub
${THIS_SH} ./alias4.sub
+${THIS_SH} ./alias5.sub
diff --git a/tests/alias1.sub b/tests/alias1.sub
index ed030312..9a90b2e2 100644
--- a/tests/alias1.sub
+++ b/tests/alias1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
shopt -s expand_aliases
alias foo=echo
diff --git a/tests/alias2.sub b/tests/alias2.sub
index 76044485..e35fb76f 100644
--- a/tests/alias2.sub
+++ b/tests/alias2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
THIS=alias2
FN=$TMPDIR/$THIS.script
diff --git a/tests/alias3.sub b/tests/alias3.sub
index bb94268a..304e9261 100644
--- a/tests/alias3.sub
+++ b/tests/alias3.sub
@@ -1,4 +1,3 @@
-#!/bin/bash
shopt -s expand_aliases
alias foo='oneword'
foo_word='foo'
diff --git a/tests/alias4.sub b/tests/alias4.sub
index 6ea513a1..0864a3c4 100644
--- a/tests/alias4.sub
+++ b/tests/alias4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
shopt -s expand_aliases
# from an austin-group report
@@ -68,3 +81,20 @@ long_comment text after
# comment
comment foo bar
+
+# alias ending in a tab
+alias foo="\
+ echo \"bar\" \
+ "
+
+foo
+
+alias foo=$'echo bad \t'
+foo
+
+# this should probably just echo a blank line to stdout
+alias foo='echo 0'
+foo>&2
+
+alias a='printf "<%s>\n" \'
+a|cat
diff --git a/tests/alias5.sub b/tests/alias5.sub
new file mode 100644
index 00000000..7f8e86d5
--- /dev/null
+++ b/tests/alias5.sub
@@ -0,0 +1,28 @@
+# 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/>.
+#
+# -c commands ending with multi-line aliases; post-bash-5.0
+
+: ${THIS_SH:=./bash}
+
+${THIS_SH} -c "shopt -s expand_aliases &>/dev/null;
+alias myalias='/bin/echo foo
+echo bar
+echo baz'
+myalias"
+
+${THIS_SH} -c "shopt -s expand_aliases &>/dev/null;
+alias myalias='echo foo
+echo bar
+echo baz'
+myalias"
diff --git a/tests/appendop.right b/tests/appendop.right
index f9609f84..f72696b1 100644
--- a/tests/appendop.right
+++ b/tests/appendop.right
@@ -15,10 +15,10 @@
4
9
16
-./appendop.tests: line 84: x: readonly variable
+./appendop.tests: line 97: x: readonly variable
declare -A foo=([two]="baz" [three]="quux" [one]="bar" )
-declare -A foo=([two]="baz" [0]="zero" [three]="quux" [one]="bar" )
-declare -A foo=([two]="baz" [0]="zero" [three]="quux" [four]="four" [one]="bar" )
+declare -A foo=([0]="zero" [two]="baz" [three]="quux" [one]="bar" )
+declare -A foo=([four]="four" [0]="zero" [two]="baz" [three]="quux" [one]="bar" )
declare -ai iarr=([0]="3" [1]="2" [2]="3")
declare -ai iarr=([0]="3" [1]="2" [2]="3" [3]="4" [4]="5" [5]="6")
25 25
diff --git a/tests/appendop.tests b/tests/appendop.tests
index e4e52c2f..61b38fc7 100644
--- a/tests/appendop.tests
+++ b/tests/appendop.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# basic cases
a=1
a+=4
diff --git a/tests/appendop1.sub b/tests/appendop1.sub
index 7101d0cc..60e70140 100644
--- a/tests/appendop1.sub
+++ b/tests/appendop1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
typeset -A foo=([one]=bar [two]=baz [three]=quux)
typeset -p foo
diff --git a/tests/appendop2.sub b/tests/appendop2.sub
index 4225ba3f..e497beb3 100644
--- a/tests/appendop2.sub
+++ b/tests/appendop2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
POSIXLY_CORRECT=1
x=2
x+=5 eval printf '"$x "'
diff --git a/tests/arith-for.right b/tests/arith-for.right
index 5c09070b..06127be8 100644
--- a/tests/arith-for.right
+++ b/tests/arith-for.right
@@ -64,11 +64,11 @@ fx ()
0
1
2
-bash: -c: line 0: syntax error: arithmetic expression required
-bash: -c: line 0: syntax error: `(( i=0; "i < 3" ))'
+bash: -c: line 1: syntax error: arithmetic expression required
+bash: -c: line 1: syntax error: `(( i=0; "i < 3" ))'
2
-bash: -c: line 0: syntax error: `;' unexpected
-bash: -c: line 0: syntax error: `(( i=0; i < 3; i++; 7 ))'
+bash: -c: line 1: syntax error: `;' unexpected
+bash: -c: line 1: syntax error: `(( i=0; i < 3; i++; 7 ))'
2
20
20
diff --git a/tests/arith-for.tests b/tests/arith-for.tests
index 33f4bd66..db913da5 100644
--- a/tests/arith-for.tests
+++ b/tests/arith-for.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
fx()
{
i=0
diff --git a/tests/arith.right b/tests/arith.right
index 2c3d172a..c74602e3 100644
--- a/tests/arith.right
+++ b/tests/arith.right
@@ -60,7 +60,7 @@
1,i+=2
30
1,j+=2
-./arith.tests: line 114: 1 ? 20 : x+=2: attempted assignment to non-variable (error token is "+=2")
+./arith.tests: line 127: 1 ? 20 : x+=2: attempted assignment to non-variable (error token is "+=2")
20
6
6,5,3
@@ -80,16 +80,16 @@
36
62
63
-./arith.tests: line 149: 3425#56: invalid arithmetic base (error token is "3425#56")
-0
-./arith.tests: line 155: 7 = 43 : attempted assignment to non-variable (error token is "= 43 ")
-./arith.tests: line 156: 2#44: value too great for base (error token is "2#44")
-./arith.tests: line 157: 44 / 0 : division by 0 (error token is "0 ")
-./arith.tests: line 158: let: jv += $iv: syntax error: operand expected (error token is "$iv")
-./arith.tests: line 159: jv += $iv : syntax error: operand expected (error token is "$iv ")
-./arith.tests: line 160: let: rv = 7 + (43 * 6: missing `)' (error token is "6")
-./arith.tests: line 164: 0#4: invalid number (error token is "0#4")
-./arith.tests: line 165: 2#110#11: invalid number (error token is "2#110#11")
+./arith.tests: line 162: 3425#56: invalid arithmetic base (error token is "3425#56")
+./arith.tests: line 165: 2#: invalid integer constant (error token is "2#")
+./arith.tests: line 168: 7 = 43 : attempted assignment to non-variable (error token is "= 43 ")
+./arith.tests: line 169: 2#44: value too great for base (error token is "2#44")
+./arith.tests: line 170: 44 / 0 : division by 0 (error token is "0 ")
+./arith.tests: line 171: let: jv += $iv: syntax error: operand expected (error token is "$iv")
+./arith.tests: line 172: jv += $iv : syntax error: operand expected (error token is "$iv ")
+./arith.tests: line 173: let: rv = 7 + (43 * 6: missing `)' (error token is "6")
+./arith.tests: line 177: 0#4: invalid number (error token is "0#4")
+./arith.tests: line 178: 2#110#11: invalid number (error token is "2#110#11")
abc
def
ghi
@@ -97,15 +97,15 @@ ok
6
1
0
-./arith.tests: line 183: 4 + : syntax error: operand expected (error token is "+ ")
+./arith.tests: line 196: 4 + : syntax error: operand expected (error token is "+ ")
16
-./arith.tests: line 188: 4 ? : 3 + 5 : expression expected (error token is ": 3 + 5 ")
-./arith.tests: line 189: 1 ? 20 : `:' expected for conditional expression (error token is "20 ")
-./arith.tests: line 190: 4 ? 20 : : expression expected (error token is ": ")
+./arith.tests: line 201: 4 ? : 3 + 5 : expression expected (error token is ": 3 + 5 ")
+./arith.tests: line 202: 1 ? 20 : `:' expected for conditional expression (error token is "20 ")
+./arith.tests: line 203: 4 ? 20 : : expression expected (error token is ": ")
9
-./arith.tests: line 196: 0 && B=42 : attempted assignment to non-variable (error token is "=42 ")
+./arith.tests: line 209: 0 && B=42 : attempted assignment to non-variable (error token is "=42 ")
9
-./arith.tests: line 199: 1 || B=88 : attempted assignment to non-variable (error token is "=88 ")
+./arith.tests: line 212: 1 || B=88 : attempted assignment to non-variable (error token is "=88 ")
9
0
9
@@ -131,11 +131,11 @@ ok
4
4
7
-./arith.tests: line 247: 7-- : syntax error: operand expected (error token is "- ")
-./arith.tests: line 249: --x=7 : attempted assignment to non-variable (error token is "=7 ")
-./arith.tests: line 250: ++x=7 : attempted assignment to non-variable (error token is "=7 ")
-./arith.tests: line 252: x++=7 : attempted assignment to non-variable (error token is "=7 ")
-./arith.tests: line 253: x--=7 : attempted assignment to non-variable (error token is "=7 ")
+./arith.tests: line 260: 7-- : syntax error: operand expected (error token is "- ")
+./arith.tests: line 262: --x=7 : attempted assignment to non-variable (error token is "=7 ")
+./arith.tests: line 263: ++x=7 : attempted assignment to non-variable (error token is "=7 ")
+./arith.tests: line 265: x++=7 : attempted assignment to non-variable (error token is "=7 ")
+./arith.tests: line 266: x--=7 : attempted assignment to non-variable (error token is "=7 ")
4
7
-7
@@ -143,10 +143,10 @@ ok
7
2
2
-./arith1.sub: line 2: 4-- : syntax error: operand expected (error token is "- ")
-./arith1.sub: line 3: 4++ : syntax error: operand expected (error token is "+ ")
-./arith1.sub: line 4: 4 -- : syntax error: operand expected (error token is "- ")
-./arith1.sub: line 5: 4 ++ : syntax error: operand expected (error token is "+ ")
+./arith1.sub: line 15: 4-- : syntax error: operand expected (error token is "- ")
+./arith1.sub: line 16: 4++ : syntax error: operand expected (error token is "+ ")
+./arith1.sub: line 17: 4 -- : syntax error: operand expected (error token is "- ")
+./arith1.sub: line 18: 4 ++ : syntax error: operand expected (error token is "+ ")
1
2
1
@@ -161,10 +161,10 @@ ok
2
-2
1
-./arith1.sub: line 35: ((: ++ : syntax error: operand expected (error token is "+ ")
+./arith1.sub: line 48: ((: ++ : syntax error: operand expected (error token is "+ ")
7
7
-./arith1.sub: line 38: ((: -- : syntax error: operand expected (error token is "- ")
+./arith1.sub: line 51: ((: -- : syntax error: operand expected (error token is "- ")
7
7
7
@@ -183,10 +183,10 @@ ok
1
4
0
-./arith2.sub: line 33: ((: -- : syntax error: operand expected (error token is "- ")
+./arith2.sub: line 46: ((: -- : syntax error: operand expected (error token is "- ")
-7
-7
-./arith2.sub: line 37: ((: ++ : syntax error: operand expected (error token is "+ ")
+./arith2.sub: line 50: ((: ++ : syntax error: operand expected (error token is "+ ")
7
7
-7
@@ -250,14 +250,14 @@ efg
0
0
8 12
-./arith.tests: line 297: ((: x=9 y=41 : syntax error in expression (error token is "y=41 ")
-./arith.tests: line 301: a b: syntax error in expression (error token is "b")
-./arith.tests: line 302: ((: a b: syntax error in expression (error token is "b")
+./arith.tests: line 310: ((: x=9 y=41 : syntax error in expression (error token is "y=41 ")
+./arith.tests: line 314: a b: syntax error in expression (error token is "b")
+./arith.tests: line 315: ((: a b: syntax error in expression (error token is "b")
42
42
42
42
42
42
-./arith.tests: line 314: 'foo' : syntax error: operand expected (error token is "'foo' ")
-./arith.tests: line 318: b[c]d: syntax error in expression (error token is "d")
+./arith.tests: line 327: 'foo' : syntax error: operand expected (error token is "'foo' ")
+./arith.tests: line 331: b[c]d: syntax error in expression (error token is "d")
diff --git a/tests/arith.tests b/tests/arith.tests
index bc9490e9..1a3501aa 100644
--- a/tests/arith.tests
+++ b/tests/arith.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set +o posix
declare -i iv jv
@@ -148,7 +161,7 @@ echo $(( 64#_ ))
# weird bases
echo $(( 3425#56 ))
-# missing number after base
+# missing number after base now generates an error
echo $(( 2# ))
# these should generate errors
diff --git a/tests/arith1.sub b/tests/arith1.sub
index 43cae806..3168fcbf 100644
--- a/tests/arith1.sub
+++ b/tests/arith1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test of redone post-increment and post-decrement code
echo $(( 4-- ))
echo $(( 4++ ))
diff --git a/tests/arith2.sub b/tests/arith2.sub
index 7eac9523..5475012b 100644
--- a/tests/arith2.sub
+++ b/tests/arith2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
echo $(( --7 ))
echo $(( ++7 ))
echo $(( -- 7 ))
diff --git a/tests/arith3.sub b/tests/arith3.sub
index a510c739..b4b18258 100644
--- a/tests/arith3.sub
+++ b/tests/arith3.sub
@@ -1,29 +1,44 @@
+# 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/>.
+#
+# this depends on the sequence of random numbers from the internal LCRNG
RANDOM=42
(( dice[RANDOM%6+1 + RANDOM%6+1]++ ))
-echo ${dice[5]}
+echo ${dice[6]}
(( ++dice[RANDOM%6+1 + RANDOM%6+1] ))
-echo ${dice[6]}
+echo ${dice[7]}
v=4
DIND=20
(( dice[DIND%6 + 1]=v ))
echo ${dice[3]}
+(( dice[DIND/v]+=2 ))
RANDOM=42
(( dice[RANDOM%6+1 + RANDOM%6+1]+=v ))
-echo ${dice[5]}
+echo ${dice[6]}
(( dice[RANDOM%6+1 + RANDOM%6+1]-=v ))
-echo ${dice[6]}
+echo ${dice[7]}
(( dice[RANDOM%6+1 + RANDOM%6+1]+=2 ))
-echo ${dice[11]}
+echo ${dice[8]}
(( dice[RANDOM%6+1 + RANDOM%6+1]*=2 ))
-echo ${dice[11]}
+echo ${dice[5]}
unset dice1 dice2
RANDOM=42
diff --git a/tests/arith5.sub b/tests/arith5.sub
index c8fdb5a9..7d5c7799 100644
--- a/tests/arith5.sub
+++ b/tests/arith5.sub
@@ -1,3 +1,19 @@
+# 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/>.
+#
+# a lot of this is technically undefined behavior due to signed 64-bit
+# integer overflow, but we're testing exception handling here
+
intmax_max=$((2**63 - 1))
intmax_min1=$((2**63))
intmax_min2=$((-2**63))
diff --git a/tests/arith6.sub b/tests/arith6.sub
index 630e917e..dec8fd03 100644
--- a/tests/arith6.sub
+++ b/tests/arith6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
function reorder
{
(( x[1] < x && (x=x[1], x[1]=$x) ))
diff --git a/tests/arith8.sub b/tests/arith8.sub
index 1ab0895e..e6f1b0d9 100644
--- a/tests/arith8.sub
+++ b/tests/arith8.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# problems with evaluation of wrong terms in conditional expressions through
# bash-4.4
diff --git a/tests/array.right b/tests/array.right
index 834e5684..2d1c51db 100644
--- a/tests/array.right
+++ b/tests/array.right
@@ -1,6 +1,6 @@
-./array.tests: line 15: syntax error near unexpected token `&'
-./array.tests: line 15: `test=(first & second)'
+./array.tests: line 28: syntax error near unexpected token `&'
+./array.tests: line 28: `test=(first & second)'
1
abcde
abcde
@@ -26,7 +26,7 @@ hello world
11
3
bdef hello world test expression test 2
-./array.tests: line 79: readonly: `a[5]': not a valid identifier
+./array.tests: line 92: readonly: `a[5]': not a valid identifier
declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
declare -ar c
declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
@@ -46,17 +46,17 @@ declare -ar c
declare -a d=([1]="" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")
declare -a e=([0]="test")
declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")
-./array.tests: line 103: a: readonly variable
-./array.tests: line 105: b[]: bad array subscript
-./array.tests: line 106: b[*]: bad array subscript
+./array.tests: line 116: a: readonly variable
+./array.tests: line 118: b[]: bad array subscript
+./array.tests: line 119: b[*]: bad array subscript
this
-./array.tests: line 109: c[-2]: bad array subscript
-./array.tests: line 110: c: bad array subscript
+./array.tests: line 122: c[-2]: bad array subscript
+./array.tests: line 123: c: bad array subscript
-./array.tests: line 112: d[7]: cannot assign list to array member
-./array.tests: line 114: []=abcde: bad array subscript
-./array.tests: line 114: [*]=last: cannot assign to non-numeric index
-./array.tests: line 114: [-65]=negative: bad array subscript
+./array.tests: line 125: d[7]: cannot assign list to array member
+./array.tests: line 127: []=abcde: bad array subscript
+./array.tests: line 127: [*]=last: cannot assign to non-numeric index
+./array.tests: line 127: [-65]=negative: bad array subscript
declare -a BASH_ARGC=()
declare -a BASH_ARGV=()
declare -a BASH_LINENO=([0]="0")
@@ -68,8 +68,8 @@ declare -a b=([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")
declare -ar c
declare -a d=([1]="test test")
declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")
-./array.tests: line 122: unset: ps1: not an array variable
-./array.tests: line 126: declare: c: cannot destroy array variables in this way
+./array.tests: line 135: unset: ps1: not an array variable
+./array.tests: line 139: declare: c: cannot destroy array variables in this way
this of
this is a test of read using arrays
this test
@@ -127,7 +127,7 @@ grep [ 123 ] *
6 7 9 5
length = 3
value = new1 new2 new3
-./array.tests: line 242: narray: unbound variable
+./array.tests: line 255: narray: unbound variable
./array1.sub: line 1: syntax error near unexpected token `('
./array1.sub: line 1: `printf "%s\n" -a a=(a 'b c')'
./array2.sub: line 1: declare: `[]=asdf': not a valid identifier
@@ -154,10 +154,10 @@ for case if then else
12 14 16 18 20
4414758999202
aaa bbb
-./array.tests: line 292: syntax error near unexpected token `<>'
-./array.tests: line 292: `metas=( <> < > ! )'
-./array.tests: line 293: syntax error near unexpected token `<>'
-./array.tests: line 293: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
+./array.tests: line 305: syntax error near unexpected token `<>'
+./array.tests: line 305: `metas=( <> < > ! )'
+./array.tests: line 306: syntax error near unexpected token `<>'
+./array.tests: line 306: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
abc 3
case 4
abc case if then else 5
@@ -203,6 +203,7 @@ e
'b
b c
$0
+declare -a A=([0]="X=a" [1]="b")
t
[3]=abcde r s t u v
e
@@ -349,10 +350,10 @@ version[agent]
version.agent
version[agent]
version.agent
-version[agent] foo[bar]
-version.agent bowl
-foo foobar] foo[bar]
-bbb bleh bleh
+foo[bar] version[agent]
+bowl version.agent
+foobar] foo foo[bar]
+bleh bbb bleh
ab]
bar
1
@@ -367,7 +368,7 @@ function function
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")
declare -a x=([0]="0" [1]="1" [2]="2" [4]="4")
-./array14.sub: line 11: unset: [-10]: bad array subscript
+./array14.sub: line 24: unset: [-10]: bad array subscript
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="five")
declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")
@@ -395,7 +396,7 @@ qux: unset array element 0: ok
0
0
1
-./array17.sub: line 30: ~: syntax error: operand expected (error token is "~")
+./array17.sub: line 43: ~: syntax error: operand expected (error token is "~")
0
0
3
@@ -410,14 +411,15 @@ one
one
two
two
-./array17.sub: line 76: ~ : syntax error: operand expected (error token is "~ ")
+./array17.sub: line 89: ~ : syntax error: operand expected (error token is "~ ")
1
argv[1] = <>
argv[2] = <>
argv[3] = <>
argv[1] = <bar>
-argv[1] = <-->
-argv[1] = <>
+argv[1] = <->
+argv[2] = <->
+argv[1] = < >
argv[1] = <qux>
argv[1] = <->
argv[2] = <->
@@ -426,8 +428,9 @@ argv[1] = <>
argv[2] = <>
argv[3] = <>
argv[1] = <bar>
-argv[1] = <-->
-argv[1] = <>
+argv[1] = <->
+argv[2] = <->
+argv[1] = < >
argv[1] = <qux>
argv[1] = <->
argv[2] = <->
@@ -440,17 +443,13 @@ declare -a foo=([0]="[0]=bar")
declare -a foo=([0]="[0]=bar")
declare -- a="(1 2 3)"
declare -a a=([0]="1" [1]="2" [2]="3")
-./array19.sub: line 46: a: 1: must use subscript when assigning associative array
-./array19.sub: line 46: a: 2: must use subscript when assigning associative array
-./array19.sub: line 46: a: 3: must use subscript when assigning associative array
-declare -A a=()
declare -- a="([0]=a [1]=b)"
declare -a a=([0]="a" [1]="b")
declare -A a=([1]="b" [0]="a" )
declare -a var=([0]="[\$(echo" [1]="total" [2]="0)]=1" [3]="[2]=2]")
declare -a var=([0]="[\$(echo total 0)]=1 [2]=2]")
declare -a var=([0]="[\$(echo" [1]="total" [2]="0)]=1" [3]="[2]=2]")
-./array19.sub: line 81: total 0: syntax error in expression (error token is "0")
+./array19.sub: line 89: total 0: syntax error in expression (error token is "0")
declare -a var=()
declare -al foo=([0]="abcde" [1]="two" [2]="three")
declare -al foo=([0]="abcde")
@@ -458,7 +457,7 @@ declare -al ar=([0]="one" [1]="two" [2]="three")
declare -a a=([2]="foo")
declare -a a=([2]="foo")
declare -a a=([1]="(var)" [2]="foo")
-./array19.sub: line 120: warning: a[1]=(var): quoted compound array assignment deprecated
+./array19.sub: line 128: warning: a[1]=(var): quoted compound array assignment deprecated
declare -a a=([1]="(var)")
declare -a a=([0]="1" [1]="2" [2]="(1 2 3)")
declare -a a=([0]="1" [1]="2" [2]="(1 2 3)")
@@ -475,15 +474,11 @@ declare -a b=([0]="/scratch/bash")
declare -a c=([0]="1" [1]="2")
declare -a d=([0]="a" [1]="b")
declare -a e=([0]="Darwin")
-./array19.sub: line 166: c: 1: must use subscript when assigning associative array
-./array19.sub: line 166: c: 2: must use subscript when assigning associative array
-./array19.sub: line 166: d: $a: must use subscript when assigning associative array
-./array19.sub: line 166: e: $(echo Darwin): must use subscript when assigning associative array
declare -A a=([0]="a b" )
declare -A b=([0]="/scratch/bash" )
-declare -A c=()
-declare -A d=()
-declare -A e=()
+declare -A c=([1]="2" )
+declare -A d=(["a b"]="" )
+declare -A e=([Darwin]="" )
a+b+c
x+b+c
a+b+c
@@ -497,8 +492,8 @@ x b c
declare -a a=([1]="2" [2]="3" [3]="4")
abcd
unset
-./array21.sub: line 17: typeset: a: not found
-./array21.sub: line 20: typeset: A: not found
+./array21.sub: line 30: typeset: a: not found
+./array21.sub: line 33: typeset: A: not found
declare -a a=()
declare -A A=()
declare -a foo=([0]="1" [1]="(4 5 6)" [2]="3")
@@ -523,16 +518,16 @@ p3
argv[1] = <y>
<X> <X> <X> <X>
<X> <X> <X> <X>
-./array23.sub: line 9: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ")
-./array23.sub: line 10: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ")
+./array23.sub: line 22: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ")
+./array23.sub: line 23: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ")
foo
0
foo
foo
foo
6
-./array23.sub: line 21: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )")
-./array23.sub: line 22: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )")
+./array23.sub: line 34: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )")
+./array23.sub: line 35: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )")
0
0
0
@@ -586,7 +581,7 @@ jkl
1. indexed:
reference:
1. 0
-./array25.sub: line 11: ' ': syntax error: operand expected (error token is "' '")
+./array25.sub: line 24: ' ': syntax error: operand expected (error token is "' '")
3. 0
4. 0
5. 0
@@ -748,17 +743,23 @@ argv[1] = <b>
argv[2] = <a>
argv[1] = <b+a>
7
-./array27.sub: line 11: a[]]=7 : syntax error: invalid arithmetic operator (error token is "]=7 ")
+./array27.sub: line 24: a[]]=7 : syntax error: invalid arithmetic operator (error token is "]=7 ")
declare -A A=([$'\t']="2" [" "]="2" )
-./array27.sub: line 23: ((: A[]]=2 : syntax error: invalid arithmetic operator (error token is "]=2 ")
+./array27.sub: line 36: ((: A[]]=2 : syntax error: invalid arithmetic operator (error token is "]=2 ")
declare -A A=([$'\t']="2" ["*"]="2" [" "]="2" ["@"]="2" )
-./array27.sub: line 32: A[]]: bad array subscript
+./array27.sub: line 45: A[]]: bad array subscript
declare -A A=([$'\t']="X" ["*"]="X" [" "]="X" ["@"]="X" )
-./array27.sub: line 40: A[]]: bad array subscript
+./array27.sub: line 53: A[]]: bad array subscript
declare -A A=([$'\t']="X" ["*"]="X" [" "]="X" ["@"]="X" )
-./array27.sub: line 48: declare: `A[]]=X': not a valid identifier
+./array27.sub: line 61: declare: `A[]]=X': not a valid identifier
declare -A A=(["*"]="X" ["@"]="X" )
-./array27.sub: line 56: declare: `A[]]=X': not a valid identifier
-./array27.sub: line 56: A[*]: bad array subscript
-./array27.sub: line 56: A[@]: bad array subscript
+./array27.sub: line 69: declare: `A[]]=X': not a valid identifier
+./array27.sub: line 69: A[*]: bad array subscript
+./array27.sub: line 69: A[@]: bad array subscript
declare -A A
+declare -a bug4=([0]="" [1]="5" [2]="" [3]="1" [4]="")
+declare -a bug=([0]="" [1]="5" [2]="" [3]="1" [4]="")
+declare -a bug2=([0]="")
+declare -a bug3=([0]="" [1]="5" [2]="" [3]="1" [4]="")
+declare -a not_bug=([0]="no" [1]="nulls")
+declare -a workaround=([0]="")
diff --git a/tests/array.tests b/tests/array.tests
index afd3df51..ba8e2254 100644
--- a/tests/array.tests
+++ b/tests/array.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# this is needed so that the bad assignments (b[]=bcde, for example) do not
# cause fatal shell errors when in posix mode
set +o posix
@@ -155,7 +168,7 @@ echo ${x[4]}
echo efgh | ( read x[1] ; echo ${x[1]} )
echo wxyz | ( declare -a x ; read x ; echo $x ; echo ${x[0]} )
-# Make sure that arrays can be used to save the positional paramters verbatim
+# Make sure that arrays can be used to save the positional parameters verbatim
set -- a 'b c' d 'e f g' h
ARGV=( [0]=$0 "$@" )
@@ -247,7 +260,7 @@ ${THIS_SH} ./array2.sub
# some old bugs and ksh93 compatibility tests
${THIS_SH} ./array3.sub
-# some compound assingment parsing problems that showed up in bash-3.1-release
+# some compound assignment parsing problems that showed up in bash-3.1-release
${THIS_SH} ./array4.sub
set +u
@@ -379,6 +392,11 @@ declare -a x=($0)
declare -a x=(\$0)
echo "${x[@]}"
+unset A Z
+Z='a b'
+A=( X=$Z )
+declare -p A
+
# tests for bash-3.1 problems
${THIS_SH} ./array5.sub
@@ -406,3 +424,4 @@ ${THIS_SH} ./array24.sub
${THIS_SH} ./array25.sub
${THIS_SH} ./array26.sub
${THIS_SH} ./array27.sub
+${THIS_SH} ./array28.sub
diff --git a/tests/array10.sub b/tests/array10.sub
index 6d5a94c9..71824804 100644
--- a/tests/array10.sub
+++ b/tests/array10.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
days=({Mon,Tues,Wednes,Thurs,Fri,Satur,Sun}day)
echo ${days[@]}
diff --git a/tests/array11.sub b/tests/array11.sub
index c4f8cad4..5961902a 100644
--- a/tests/array11.sub
+++ b/tests/array11.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# problems with associative array keys with ] and unbalanced [ ]
# fixed after bash-4.2
diff --git a/tests/array12.sub b/tests/array12.sub
index 65711385..fbf5eeb0 100644
--- a/tests/array12.sub
+++ b/tests/array12.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# problems with fix for posix interp 217 introduced in bash-4.2
declare -ax array
diff --git a/tests/array13.sub b/tests/array13.sub
index 736f210c..635cb977 100644
--- a/tests/array13.sub
+++ b/tests/array13.sub
@@ -1,4 +1,3 @@
-#!/bin/bash
func1(){
declare -g variable='function'
diff --git a/tests/array14.sub b/tests/array14.sub
index 7715169c..57a455a6 100644
--- a/tests/array14.sub
+++ b/tests/array14.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# start at a test suite for negative indexed array subscripts -- post bash-4.2
x=( 0 1 2 3 4 5)
declare -p x
diff --git a/tests/array15.sub b/tests/array15.sub
index b056ccbb..47796b95 100644
--- a/tests/array15.sub
+++ b/tests/array15.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# fixes for make_internal_declare not handling integer attribute for arrays
declare -ai -g foo=(1 2 xx 3)
echo "${foo[@]}"
diff --git a/tests/array16.sub b/tests/array16.sub
index 10024bc1..b82dbca2 100644
--- a/tests/array16.sub
+++ b/tests/array16.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
foo[0]=a
foo[1]=b
diff --git a/tests/array17.sub b/tests/array17.sub
index 302dc039..dd0c0f69 100644
--- a/tests/array17.sub
+++ b/tests/array17.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# this shows the expansions an array subscript undergoes before being run
# through the arithmetic evaluator
diff --git a/tests/array18.sub b/tests/array18.sub
index 675b194e..95030812 100644
--- a/tests/array18.sub
+++ b/tests/array18.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# arrays referenced using @ subscript and positional parameters should behave
# the same way
diff --git a/tests/array19.sub b/tests/array19.sub
index adfad82a..1d02f744 100644
--- a/tests/array19.sub
+++ b/tests/array19.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# tests for changes to declare and assignment statement arguments post-bash-4.3
unset foo l a b
@@ -42,11 +55,6 @@ declare a='(1 2 3)'
declare -p a
unset a
-declare -A a
-declare a='(1 2 3)'
-declare -p a
-unset a
-
declare a='([0]=a [1]=b)'
declare -p a
unset a
diff --git a/tests/array20.sub b/tests/array20.sub
index 035d936b..24dff930 100644
--- a/tests/array20.sub
+++ b/tests/array20.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# tests to make sure that $* and ${array[*]} expand consistently in `list'
# and `scalar' contexts
diff --git a/tests/array21.sub b/tests/array21.sub
index d1f705e3..97ff0936 100644
--- a/tests/array21.sub
+++ b/tests/array21.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
typeset -a a
a=(1 2 3 4)
diff --git a/tests/array22.sub b/tests/array22.sub
index adae6e1a..3374ef2f 100644
--- a/tests/array22.sub
+++ b/tests/array22.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# This isn't perfect behavior, but it establishes a baseline and will provide
# a way to detect behavior changes
diff --git a/tests/array23.sub b/tests/array23.sub
index bd64fe1f..02d271db 100644
--- a/tests/array23.sub
+++ b/tests/array23.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# this captures how bash and ksh93 expand indexed array subscripts in
# various contexts. if changes are ever made, or an option added to do
# this differently, the diffs will show up here
diff --git a/tests/array24.sub b/tests/array24.sub
index 108f761b..461b4068 100644
--- a/tests/array24.sub
+++ b/tests/array24.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- "abc" "def ghi" "jkl"
A=("$@")
diff --git a/tests/array25.sub b/tests/array25.sub
index b550d9d5..fe6bb348 100644
--- a/tests/array25.sub
+++ b/tests/array25.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# tests with blank subscripts, indexed and associative
echo 1. indexed:
diff --git a/tests/array26.sub b/tests/array26.sub
index 826774f7..0f6cc8fa 100644
--- a/tests/array26.sub
+++ b/tests/array26.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# these should produce the same results
a=(aa bb)
set -- aa bb
diff --git a/tests/array27.sub b/tests/array27.sub
index fe1ffd35..44ed444d 100644
--- a/tests/array27.sub
+++ b/tests/array27.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# tests for `problem' keys when using associative arrays and assoc_expand_once
# deal with problems for now; this is a placeholder for if and when I fix them
diff --git a/tests/array28.sub b/tests/array28.sub
new file mode 100644
index 00000000..e11cdb6d
--- /dev/null
+++ b/tests/array28.sub
@@ -0,0 +1,30 @@
+# 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/>.
+#
+
+# tests for assigning empty string array elements without subscripts
+function foo()
+{
+ local bug=("" "5" "" 1 "")
+ declare -a bug2=("")
+ declare -ga bug3=("" "5" "" 1 "")
+ local not_bug=("no" "nulls")
+ local workaround; workaround=("")
+
+ declare -p bug bug2 bug3 not_bug workaround
+}
+
+declare -a bug4=("" "5" "" 1 "")
+declare -p bug4
+
+foo
diff --git a/tests/array4.sub b/tests/array4.sub
index 97c766db..443a0fd8 100644
--- a/tests/array4.sub
+++ b/tests/array4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# compound assignment parsing problems in bash-3.1-release
func()
{
diff --git a/tests/array5.sub b/tests/array5.sub
index 00953c4a..0dda6969 100644
--- a/tests/array5.sub
+++ b/tests/array5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${TMPDIR:=/tmp}
diff --git a/tests/array6.sub b/tests/array6.sub
index 0017f4cd..2c6c3502 100644
--- a/tests/array6.sub
+++ b/tests/array6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test cases for array quoting and escaping fixed post bash-3.2-release
oIFS="$IFS"
diff --git a/tests/array8.sub b/tests/array8.sub
index 481ccdbc..6e7e2d6c 100644
--- a/tests/array8.sub
+++ b/tests/array8.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
IFS=/
declare -a i
diff --git a/tests/array9.sub b/tests/array9.sub
index 444247fa..c3aa31d1 100644
--- a/tests/array9.sub
+++ b/tests/array9.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
echo $(( 0x7e ))
echo $(( 0x7f ))
echo $(( 0x80 ))
diff --git a/tests/assoc.right b/tests/assoc.right
index 90abb6d6..e9aa9172 100644
--- a/tests/assoc.right
+++ b/tests/assoc.right
@@ -6,18 +6,18 @@ declare -A BASH_CMDS=()
declare -A fluff=([foo]="one" [bar]="two" )
declare -A fluff=([foo]="one" [bar]="two" )
declare -A fluff=([bar]="two" )
-declare -A fluff=([bar]="newval" [qux]="assigned" )
-./assoc.tests: line 26: chaff: four: must use subscript when assigning associative array
+declare -A fluff=([qux]="assigned" [bar]="newval" )
+./assoc.tests: line 39: chaff: four: must use subscript when assigning associative array
declare -A BASH_ALIASES=()
declare -A BASH_CMDS=()
-declare -Ai chaff=([zero]="5" [one]="10" )
-declare -Ar waste=([lineno]="28" [source]="./assoc.tests" [version]="4.0-devel" [pid]="42134" )
-declare -A wheat=([two]="b" [three]="c" [zero]="0" [one]="a" )
-declare -A chaff=(["hello world"]="flip" [zero]="5" [one]="10" )
-./assoc.tests: line 38: waste: readonly variable
-./assoc.tests: line 39: unset: waste: cannot unset: readonly variable
-./assoc.tests: line 40: chaff[*]: bad array subscript
-./assoc.tests: line 41: [*]=12: invalid associative array key
+declare -Ai chaff=([one]="10" [zero]="5" )
+declare -Ar waste=([pid]="42134" [lineno]="41" [source]="./assoc.tests" [version]="4.0-devel" )
+declare -A wheat=([two]="b" [three]="c" [one]="a" [zero]="0" )
+declare -A chaff=(["hello world"]="flip" [one]="10" [zero]="5" )
+./assoc.tests: line 51: waste: readonly variable
+./assoc.tests: line 52: unset: waste: cannot unset: readonly variable
+./assoc.tests: line 53: chaff[*]: bad array subscript
+./assoc.tests: line 54: [*]=12: invalid associative array key
declare -A chaff=(["hello world"]="flip" [one]="a" )
flip
argv[1] = <multiple>
@@ -32,14 +32,14 @@ argv[2] = <words>
argv[3] = <flip>
argv[4] = <a>
argv[1] = <multiple words flip a>
-./assoc.tests: line 58: declare: chaff: cannot destroy array variables in this way
-./assoc.tests: line 60: chaff[*]: bad array subscript
-./assoc.tests: line 61: [*]=12: invalid associative array key
-declare -A wheat=(["foo bar"]="qux qix" [six]="6" )
+./assoc.tests: line 71: declare: chaff: cannot destroy array variables in this way
+./assoc.tests: line 73: chaff[*]: bad array subscript
+./assoc.tests: line 74: [*]=12: invalid associative array key
+declare -A wheat=([six]="6" ["foo bar"]="qux qix" )
argv[1] = <qux>
argv[2] = <qix>
argv[1] = <qux qix>
-declare -A wheat=(["foo bar"]="qux qix" [six]="6" )
+declare -A wheat=([six]="6" ["foo bar"]="qux qix" )
argv[1] = <2>
argv[1] = <7>
argv[1] = <qux>
@@ -48,16 +48,16 @@ argv[3] = <blat>
argv[1] = <qux qix blat>
argv[1] = <16>
argv[1] = <16>
-argv[1] = <flix>
-argv[2] = <6>
-argv[1] = <foo>
-argv[2] = <bar>
-argv[3] = <six>
-argv[1] = <foo bar>
-argv[2] = <six>
+argv[1] = <6>
+argv[2] = <flix>
+argv[1] = <six>
+argv[2] = <foo>
+argv[3] = <bar>
+argv[1] = <six>
+argv[2] = <foo bar>
8
-/sbin /usr/bin /bin /usr/ucb /usr/local/bin . /usr/sbin /bin
-sbin bin bin ucb bin . sbin bin
+/usr/local/bin /bin . /usr/bin /usr/ucb /usr/sbin /bin /sbin
+bin bin . bin ucb sbin bin sbin
bin
/ / / / / / /
/
@@ -66,27 +66,27 @@ argv[1] = </>
argv[1] = <sbin>
argv[1] = </>
8
-/sbin /usr/bin /bin /usr/ucb /usr/local/bin . /usr/sbin /bin
-sbin bin bin ucb bin . sbin bin
+/usr/local/bin /bin . /usr/bin /usr/ucb /usr/sbin /bin /sbin
+bin bin . bin ucb sbin bin sbin
/ / / / / / /
8
4 -- /bin
-^sbin ^usr^bin ^bin ^usr^ucb ^usr^local^bin . ^usr^sbin ^bin
-^sbin ^usr^bin ^bin ^usr^ucb ^usr^local^bin . ^usr^sbin ^bin
-\sbin \usr/bin \bin \usr/ucb \usr/local/bin . \usr/sbin \bin
-\sbin \usr\bin \bin \usr\ucb \usr\local\bin . \usr\sbin \bin
-\sbin \usr\bin \bin \usr\ucb \usr\local\bin . \usr\sbin \bin
+^usr^local^bin ^bin . ^usr^bin ^usr^ucb ^usr^sbin ^bin ^sbin
+^usr^local^bin ^bin . ^usr^bin ^usr^ucb ^usr^sbin ^bin ^sbin
+\usr/local/bin \bin . \usr/bin \usr/ucb \usr/sbin \bin \sbin
+\usr\local\bin \bin . \usr\bin \usr\ucb \usr\sbin \bin \sbin
+\usr\local\bin \bin . \usr\bin \usr\ucb \usr\sbin \bin \sbin
([a]=1)
foo qux
/usr/sbin/foo /usr/local/bin/qux
hits command
- 0 /sbin/blat
0 /usr/sbin/foo
0 /bin/sh
+ 0 /sbin/blat
0 /usr/local/bin/qux
-blat foo sh qux
-/sbin/blat /usr/sbin/foo /bin/sh /usr/local/bin/qux
+foo sh blat qux
+/usr/sbin/foo /bin/sh /sbin/blat /usr/local/bin/qux
foo qux
argv[1] = </usr/sbin/foo>
@@ -104,10 +104,10 @@ argv[4] = </usr/local/bin/qux -l>
outside: outside
declare -A BASH_ALIASES=()
declare -A BASH_CMDS=()
-declare -A afoo=(["foo bar"]="foo quux" [six]="six" )
+declare -A afoo=([six]="six" ["foo bar"]="foo quux" )
argv[1] = <inside:>
-argv[2] = <foo quux>
-argv[3] = <six>
+argv[2] = <six>
+argv[3] = <foo quux>
outside 2: outside
argv[1] = </barq//fooq>
argv[1] = <>
@@ -137,12 +137,12 @@ argv[4] = <FOOQ>
abc
def
def
-./assoc5.sub: line 13: declare: `myarray[foo[bar]=bleh': not a valid identifier
-bleh def abc
-myarray=([foo]="bleh" ["]"]="def" ["a]=test1;#a"]="123" ["a]a"]="abc" )
+./assoc5.sub: line 26: declare: `myarray[foo[bar]=bleh': not a valid identifier
+def bleh abc
+myarray=(["]"]="def" [foo]="bleh" ["a]a"]="abc" ["a]=test1;#a"]="123" )
123
-myarray=([foo]="bleh" ["]"]="def" ["a]=test2;#a"]="def" ["a]=test1;#a"]="123" ["a]a"]="abc" )
+myarray=(["]"]="def" ["a]=test2;#a"]="def" [foo]="bleh" ["a]a"]="abc" ["a]=test1;#a"]="123" )
bar"bie
doll
declare -A foo=(["bar\"bie"]="doll" )
@@ -195,13 +195,15 @@ declare -A assoc=([0]="assoc" )
assoc
declare -A assoc=([two]="twoless" [three]="three" [one]="onemore" )
declare -Ar assoc=([two]="twoless" [three]="three" [one]="onemore" )
+declare -A hash=([key]="value1" )
+declare -A hash=([key]="value1 value2" )
declare -A b=([")"]="" ["\""]="" ["]"]="" ["\\"]="" ["\`"]="" )
declare -A b=(["]"]="" ["\`"]="" )
declare -A dict=(["'"]="3" ["\""]="1" ["\\"]="4" ["\`"]="2" )
-./assoc9.sub: line 23: unset: `dict[']': not a valid identifier
-./assoc9.sub: line 23: unset: `dict["]': not a valid identifier
-./assoc9.sub: line 23: unset: `dict[\]': not a valid identifier
-./assoc9.sub: line 23: unset: `dict[`]': not a valid identifier
+./assoc9.sub: line 36: unset: `dict[']': not a valid identifier
+./assoc9.sub: line 36: unset: `dict["]': not a valid identifier
+./assoc9.sub: line 36: unset: `dict[\]': not a valid identifier
+./assoc9.sub: line 36: unset: `dict[`]': not a valid identifier
declare -A dict=(["'"]="3" ["\""]="1" ["\\"]="4" ["\`"]="2" )
declare -A dict=(["'"]="3" ["\""]="1" ["\\"]="4" ["\`"]="2" )
declare -A dict=()
@@ -209,10 +211,10 @@ declare -A dict=()
4
a[$b]= 5
declare -A a=(["80's"]="Depeche Mode" )
-./assoc9.sub: line 71: read: `a[80's]': not a valid identifier
+./assoc9.sub: line 84: read: `a[80's]': not a valid identifier
declare -A a
declare -A a=(["80's"]="Depeche Mode" )
-./assoc9.sub: line 83: printf: `a[80's]': not a valid identifier
+./assoc9.sub: line 96: printf: `a[80's]': not a valid identifier
declare -A a
declare -A a=(["80's"]="Depeche Mode" )
6
@@ -220,12 +222,39 @@ declare -A a=(["80's"]="Depeche Mode" )
1+5
declare -A a=(["\$(date >&2)"]="5" )
declare -A myarray=([foo]="bleh" ["foo[bar"]="bleh" )
-./assoc10.sub: line 1: declare: a: cannot convert indexed to associative array
+foo
+./assoc10.sub: line 14: declare: a: cannot convert indexed to associative array
f: declare -a a
-./assoc10.sub: line 4: declare: a: cannot convert associative to indexed array
+./assoc10.sub: line 17: declare: a: cannot convert associative to indexed array
f: declare -A a
f: declare -a a
main: declare -- a="7"
f: declare -A a
main: declare -- a="42"
+declare -A a=([3]="" [1]="2" )
+declare -A foo=([d]="4" [c]="3" [b]="2" [a]="1" )
+foo=( d "4" c "3" b "2" a "1" )
+declare -A foo=(["\\"]="5" ["@"]="3" ["holy hell this works"]="4" ["a b"]="1" ["spa ces"]="2" )
+foo=( echo "\\" "5" "@" "3" "holy hell this works" "4" "a b" "1" "spa ces" "2" )
+./assoc11.sub: line 34: "": bad array subscript
+declare -A foo=([";"]="semicolon" ["]"]="def" [a=b]="assignment" ["a]a"]="abc" ["foo[bar"]="bleh" )
+foo=( ";" "semicolon" "]" "def" a=b "assignment" "a]a" "abc" "foo[bar" "bleh" )
+declare -A foo=(["'"]="squote" ["\""]="dquote" ["\\"]="bslash" ["\`"]="backquote" )
+foo=( "'" "squote" "\"" "dquote" "\\" "bslash" "\`" "backquote" )
+declare -A foo=(["bar]bie"]="doll" ["a]=test1;#a"]="123" ["bar\"bie"]="doll" )
+foo=( "bar]bie" "doll" "a]=test1;#a" "123" "bar\"bie" "doll" )
+declare -A inside=([c]="3" [b]="2" [a]="1" )
+inside=( c "3" b "2" a "1" )
+declare -A dict=(["?"]="quest" ["*"]="star" ["'"]="squote" ["\$"]="dol" ["\""]="dquote" ["\\"]="bslash" ["@"]="at" ["}"]="rbrace" ["{"]="lbrace" ["\`"]="bquote" )
+dict=( "?" "quest" "*" "star" "'" "squote" "\$" "dol" "\"" "dquote" "\\" "bslash" "@" "at" "}" "rbrace" "{" "lbrace" "\`" "bquote" )
+declare -A foo=([two]="" [one]="1" )
+foo=( two "" one "1" )
+rparen dquote rbrace bs
+declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
+")" "rparen" "\"" "dquote" "]" "rbrace" "\\" "bs"
+declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
+declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
+declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
+declare -Arx foo=([two]="2" [three]="3" [one]="1" )
+./assoc11.sub: line 90: foo: readonly variable
diff --git a/tests/assoc.tests b/tests/assoc.tests
index 84326c9c..8d5c8927 100644
--- a/tests/assoc.tests
+++ b/tests/assoc.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# TEST - basic declaration and assignment
typeset -A fluff
declare -A
@@ -18,7 +31,7 @@ declare -p fluff
unset fluff
-# TEST - compount assignment and variable attributes
+# TEST - compound assignment and variable attributes
declare -A wheat chaff
wheat=( [zero]=0 [one]=a [two]=b [three]=c )
@@ -213,9 +226,21 @@ declare -p assoc
readonly -A assoc
declare -p assoc
+declare -A hash
+
+hash=(["key"]="value1")
+declare -p hash
+hash=(["key"]="${hash["key"]} value2")
+declare -p hash
+
+unset hash
+
${THIS_SH} ./assoc8.sub
# new shopt option to prevent multiple expansion of assoc array subscripts
${THIS_SH} ./assoc9.sub
${THIS_SH} ./assoc10.sub
+
+# test assigning associative arrays using compound key/value pair assignments
+${THIS_SH} ./assoc11.sub
diff --git a/tests/assoc1.sub b/tests/assoc1.sub
index a045bde9..99a6e22a 100644
--- a/tests/assoc1.sub
+++ b/tests/assoc1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
hash -r
echo ${BASH_CMDS[@]}
diff --git a/tests/assoc10.sub b/tests/assoc10.sub
index 9eef2cac..5b215258 100644
--- a/tests/assoc10.sub
+++ b/tests/assoc10.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
f() { declare -a a; declare -A a; echo -n "$FUNCNAME: " ; declare -p a; }
f
diff --git a/tests/assoc11.sub b/tests/assoc11.sub
new file mode 100644
index 00000000..13111a52
--- /dev/null
+++ b/tests/assoc11.sub
@@ -0,0 +1,90 @@
+# 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/>.
+#
+# these tests were previously in array19.sub, but they are acceptable syntax now
+
+declare -A a
+declare a='(1 2 3)'
+declare -p a
+unset a
+
+declare -A foo
+
+v1='spa ces'
+v2=@
+
+foo=(a 1 b 2 c 3 d 4 )
+declare -p foo
+echo foo=\( ${foo[@]@K} \)
+
+foo=('a b' 1 "$v1" 2 "$v2" 3 'holy hell this works' 4 \\ 5)
+declare -p foo
+echo foo=\( echo ${foo[@]@K} \)
+
+foo=( "" null )
+
+foo=('a]a' abc ']' def $(echo 'foo[bar') bleh \; semicolon a=b assignment)
+declare -p foo
+echo foo=\( ${foo[@]@K} \)
+
+foo=('`' backquote '"' dquote "'" squote \\ bslash)
+declare -p foo
+echo foo=\( ${foo[@]@K} \)
+
+bar='a]=test1;#a'
+foo=( $bar 123 bar\"bie doll bar]bie doll )
+declare -p foo
+echo foo=\( ${foo[@]@K} \)
+
+func()
+{
+ declare -A inside=(a 1 b 2 c 3)
+ declare -p inside
+ echo inside=\( ${inside[@]@K} \)
+}
+func
+
+loaddict()
+{
+ dict=( '"' dquote '`' bquote "'" squote '\' bslash)
+ dict+=( '$' dol @ at * star \{ lbrace \} rbrace ? quest)
+
+ declare -p dict
+ echo dict=\( ${dict[@]@K} \)
+}
+declare -A dict
+loaddict
+
+foo=(one 1 two)
+declare -p foo
+echo foo=\( ${foo[@]@K} \)
+
+typeset -A a=( [\\]=bs [\"]=dquote [\)]=rparen [\]]=rbrace )
+echo ${a[@]}
+declare -p a
+
+echo ${a[@]@K}
+echo ${a[@]@A}
+
+eval "${a[@]@A}"
+declare -p a
+
+eval "a=( ${a[@]@K} )"
+declare -p a
+
+unset a foo
+readonly -A foo=( one 1 two 2 three 3 )
+
+export foo
+declare -p foo
+declare foo+=( seven 7 eight 8 )
diff --git a/tests/assoc2.sub b/tests/assoc2.sub
index 396b87a3..470e2c94 100644
--- a/tests/assoc2.sub
+++ b/tests/assoc2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
echo ${BASH_ALIASES[@]}
alias foo=/usr/sbin/foo
diff --git a/tests/assoc3.sub b/tests/assoc3.sub
index 9129ef1d..a7eeb265 100644
--- a/tests/assoc3.sub
+++ b/tests/assoc3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
foo()
{
declare -A afoo=([six]="six" [foo bar]="foo quux")
diff --git a/tests/assoc4.sub b/tests/assoc4.sub
index 1516dc58..eff9d0e8 100644
--- a/tests/assoc4.sub
+++ b/tests/assoc4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
IFS=/
declare -A i
diff --git a/tests/assoc5.sub b/tests/assoc5.sub
index 400f3d39..844d9441 100644
--- a/tests/assoc5.sub
+++ b/tests/assoc5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
declare -A myarray
# this needs fixes to skipsubscript
diff --git a/tests/assoc6.sub b/tests/assoc6.sub
index 54112ee5..88b8eaf2 100644
--- a/tests/assoc6.sub
+++ b/tests/assoc6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
declare -A foo
foo=([bar\"bie]=doll)
diff --git a/tests/assoc7.sub b/tests/assoc7.sub
index 5bc5150e..cae57c55 100644
--- a/tests/assoc7.sub
+++ b/tests/assoc7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# problem with bash versions through bash-4.2
foo()
{
diff --git a/tests/assoc9.sub b/tests/assoc9.sub
index c5fbe45b..b8867187 100644
--- a/tests/assoc9.sub
+++ b/tests/assoc9.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
typeset -A a=( [\\]= [\"]= [\)]= ) b
for x in "${!a[@]}"; do b[$x]=; done
b+=([\`]= [\]]=)
@@ -108,3 +121,10 @@ declare myarray["foo[bar"]=bleh
myarray["foo"]=bleh
declare -p myarray
+
+key='$(date >&2)'
+declare -A aa
+aa[$key]=foo
+echo "${aa[$key]}"
+
+[[ -v aa[$key] ]] || echo bad assoc expansion
diff --git a/tests/attr.right b/tests/attr.right
index 631b3f41..d2d28b7b 100644
--- a/tests/attr.right
+++ b/tests/attr.right
@@ -1,9 +1,9 @@
after f1:declare -ar a=([0]="1")
-./attr.tests: line 4: a: readonly variable
+./attr.tests: line 17: a: readonly variable
after f2:declare -ar a=([0]="1")
-./attr.tests: line 5: a: readonly variable
+./attr.tests: line 18: a: readonly variable
after f3:declare -ar a=([0]="1")
-./attr.tests: line 6: readonly: a: readonly variable
+./attr.tests: line 19: readonly: a: readonly variable
after f4:declare -ar a=([0]="1")
after f2:declare -ar b=([0]="2")
after f3:declare -ar c=([0]="(3)")
@@ -11,15 +11,15 @@ after f4:declare -ar d=([0]="4")
declare -r m="4"
in func:declare -r n="4"
declare -r n="4"
-./attr1.sub: line 13: p: readonly variable
+./attr1.sub: line 26: p: readonly variable
declare -r p="1"
-./attr1.sub: line 19: r: readonly variable
+./attr1.sub: line 32: r: readonly variable
declare -ar r=([0]="1")
-./attr1.sub: line 23: r: readonly variable
+./attr1.sub: line 36: r: readonly variable
declare -ar r=([0]="1")
-./attr1.sub: line 27: r: readonly variable
+./attr1.sub: line 40: r: readonly variable
declare -ar r=([0]="1")
-./attr1.sub: line 31: readonly: r: readonly variable
+./attr1.sub: line 44: readonly: r: readonly variable
declare -ar r=([0]="1")
declare -ar x=([0]="4")
in func:declare -ar y=([0]="4")
diff --git a/tests/attr.tests b/tests/attr.tests
index b5e01596..4874d9a7 100644
--- a/tests/attr.tests
+++ b/tests/attr.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
a=(outside)
f1() { readonly a=(1) ; }
diff --git a/tests/attr1.sub b/tests/attr1.sub
index 1c0609ab..4424be95 100644
--- a/tests/attr1.sub
+++ b/tests/attr1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
m=1
readonly m=4
declare -p m
diff --git a/tests/attr2.sub b/tests/attr2.sub
index 28d447cc..dadca10b 100644
--- a/tests/attr2.sub
+++ b/tests/attr2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
p=1
export p
diff --git a/tests/braces.tests b/tests/braces.tests
index a80cf450..da0b624b 100644
--- a/tests/braces.tests
+++ b/tests/braces.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
echo ff{c,b,a}
echo f{d,e,f}g
echo {l,n,m}xyz
diff --git a/tests/builtins.right b/tests/builtins.right
index 32db2a53..832472f6 100644
--- a/tests/builtins.right
+++ b/tests/builtins.right
@@ -105,9 +105,9 @@ m n o p
/tmp/bash-dir-a
/tmp/bash-dir-a
/tmp/bash-dir-a
-./source5.sub: line 10: /tmp/source-notthere: No such file or directory
+./source5.sub: line 23: /tmp/source-notthere: No such file or directory
after bad source 1
-./source5.sub: line 17: /tmp/source-notthere: No such file or directory
+./source5.sub: line 30: /tmp/source-notthere: No such file or directory
one - OK
0
0
@@ -144,11 +144,11 @@ AVAR
foo
declare -x foo=""
declare -x FOO="\$\$"
-./builtins.tests: line 213: declare: FOO: not found
+./builtins.tests: line 226: declare: FOO: not found
declare -x FOO="\$\$"
ok
ok
-./builtins.tests: line 245: kill: 4096: invalid signal specification
+./builtins.tests: line 258: kill: 4096: invalid signal specification
1
a\n\n\nb
a
@@ -208,8 +208,8 @@ f2 ()
all unset:
unset1
unset2
-./builtins6.sub: line 28: declare: f1: not found
-./builtins6.sub: line 28: declare: f2: not found
+./builtins6.sub: line 41: declare: f1: not found
+./builtins6.sub: line 41: declare: f2: not found
all reset:
one-one
two-one
@@ -235,4 +235,40 @@ f2 ()
funcs unset:
one-two
two-two
-./builtins.tests: line 266: exit: status: numeric argument required
+bash: line 1: notthere: No such file or directory
+one
+bash: line 1: notthere: No such file or directory
+two
+bash: line 1: .: notthere: file not found
+one
+bash: line 1: .: notthere: file not found
+0
+0
+0
+0
+argv[1] = <one>
+0
+argv[1] = <two>
+0
+three
+0
+four
+0
+./builtins7.sub: line 19: : command not found
+127
+0
+./builtins7.sub: line 27: notthere: No such file or directory
+after 1
+./builtins7.sub: line 28: notthere: No such file or directory
+after 2
+type is a shell builtin
++ command -v type
+type
++ command command -v type
+type
++ command -p command -v type
+type
++ command -p -- command -v type
+type
++ set +x
+./builtins.tests: line 282: exit: status: numeric argument required
diff --git a/tests/builtins.tests b/tests/builtins.tests
index ac74fe6f..00ebc0fd 100644
--- a/tests/builtins.tests
+++ b/tests/builtins.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# tests for miscellaneous builtins not tested elsewhere
set +p
set +o posix
@@ -124,7 +137,7 @@ hash -r
hash
# this had better succeed, since command -p guarantees we will find the
-# standard utilties
+# standard utilities
command -p hash rm
# check out source/.
@@ -173,7 +186,7 @@ echo "$@"
# test out cd and $CDPATH
${THIS_SH} ./builtins1.sub
-# test behavior of `.' when given a non-existant file argument
+# test behavior of `.' when given a non-existent file argument
${THIS_SH} ./source5.sub
# test bugs in sourcing non-regular files, fixed post-bash-3.2
@@ -262,6 +275,9 @@ ${THIS_SH} ./builtins5.sub
# test behavior of unset builtin with -f and -v options
${THIS_SH} ./builtins6.sub
+# test behavior of command builtin after changing it to a pseudo-keyword
+${THIS_SH} ./builtins7.sub
+
# this must be last -- it is a fatal error
exit status
diff --git a/tests/builtins4.sub b/tests/builtins4.sub
index b7d0c0c9..058ee2c1 100644
--- a/tests/builtins4.sub
+++ b/tests/builtins4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
declare -a c
declare -p c
diff --git a/tests/builtins5.sub b/tests/builtins5.sub
index 9a5dd7b9..d36e03a5 100644
--- a/tests/builtins5.sub
+++ b/tests/builtins5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# a start at a test suite for what it means for an array to be set or unset and
# how to test that state
typeset -A A
diff --git a/tests/builtins6.sub b/tests/builtins6.sub
index c18b4766..d4fdf4ae 100644
--- a/tests/builtins6.sub
+++ b/tests/builtins6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
f1()
{
echo f1
diff --git a/tests/builtins7.sub b/tests/builtins7.sub
new file mode 100644
index 00000000..67e5e610
--- /dev/null
+++ b/tests/builtins7.sub
@@ -0,0 +1,38 @@
+: ${THIS_SH:=./bash}
+
+${THIS_SH} -c 'command . notthere ; echo one' bash
+${THIS_SH} -c '. notthere ; echo two' bash
+
+${THIS_SH} -o posix -c 'command . notthere ; echo one' bash
+${THIS_SH} -o posix -c '. notthere ; echo two' bash
+
+command ; echo $?
+command -- ; echo $?
+command -p ; echo $?
+command -p -- ; echo $?
+
+command recho one; echo $?
+command -- recho two; echo $?
+command -p echo three; echo $?
+command -p -- echo four ; echo $?
+
+command ''
+echo $?
+
+command -p
+echo $?
+
+${THIS_SH} -c 'set -e ; command false ; echo after' bash
+
+command command command -p . notthere ; echo after 1
+command -p command command . notthere ; echo after 2
+
+command -p command -V type
+
+set -x
+command -v type
+command command -v type
+command -p command -v type
+command -p -- command -v type
+set +x
+
diff --git a/tests/case.right b/tests/case.right
index d2055c9d..557bcadf 100644
--- a/tests/case.right
+++ b/tests/case.right
@@ -5,7 +5,7 @@ retest
and match
no more clauses
1.0
-./case.tests: line 29: xx: readonly variable
+./case.tests: line 42: xx: readonly variable
1.1
matches 1
no
diff --git a/tests/case.tests b/tests/case.tests
index fe9c05a7..2ffcb906 100644
--- a/tests/case.tests
+++ b/tests/case.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
case foo in
bar) echo skip ;;
foo) echo fallthrough ;&
diff --git a/tests/case1.sub b/tests/case1.sub
index 7db09ab2..80771118 100644
--- a/tests/case1.sub
+++ b/tests/case1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
x='\x'
case x in
diff --git a/tests/case2.sub b/tests/case2.sub
index 085f888c..6c3be38e 100644
--- a/tests/case2.sub
+++ b/tests/case2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
x=$'\\a\\b\\c\\\001\\d\\e\\f'
y='\a\b\c\\d\e\f'
z=$'abc\001def'
diff --git a/tests/case3.sub b/tests/case3.sub
index 77526c32..1e8d785c 100644
--- a/tests/case3.sub
+++ b/tests/case3.sub
@@ -1,4 +1,16 @@
-#!/bin/sh
+# 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/>.
+#
testmatch() {
case $1 in
diff --git a/tests/case4.sub b/tests/case4.sub
index 56f88baa..ababeb94 100644
--- a/tests/case4.sub
+++ b/tests/case4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
shopt -s -o posix
two="t w o"
ten="t e
diff --git a/tests/casemod.right b/tests/casemod.right
index a5840171..df124754 100644
--- a/tests/casemod.right
+++ b/tests/casemod.right
@@ -43,7 +43,5 @@ Be Conservative in what you send and Liberal in what you accept
BE CONSERVATIVE IN WHAT YOU SEND AND LIBERAL IN WHAT YOU ACCEPT
Be conservative in what you send and liberal in what you accept
BE CONSERVATIVE IN WHAT YOU SEND AND LIBERAL IN WHAT YOU ACCEPT
-AcknOwlEdgEmEnt acknOwlEdgEmEnt
-oeNoPHiLe OEnOphIlE
abcdexyz
ABCDEXYZ
diff --git a/tests/casemod.tests b/tests/casemod.tests
index dacdb0a8..56ab20d9 100644
--- a/tests/casemod.tests
+++ b/tests/casemod.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
S1=acknowledgement
S2=oenophile
@@ -101,8 +114,8 @@ echo ${TEXT2^^}
M1=${S1^^[aeiou]}
M2=${U2,,[AEIOU]}
-echo ${M1} ${M1~}
-echo ${M2} ${M2~~}
+#echo ${M1} ${M1~}
+#echo ${M2} ${M2~~}
declare -l lower=aBcDe
lower+=XyZ
diff --git a/tests/complete.right b/tests/complete.right
new file mode 100644
index 00000000..5bc89a05
--- /dev/null
+++ b/tests/complete.right
@@ -0,0 +1,63 @@
+complete -f -X '!*.+(ps|PS)' gs
+complete -c nice
+complete -e printenv
+complete -c gdb
+complete -f -X '!*.texi*' texi2html
+complete -j -P '%' fg
+complete -g groupmod
+complete -f -X '!*.dvi' dvips
+complete -f -X '!*.texi*' texi2dvi
+complete -v -S '=' typeset
+complete -f .
+complete -c nohup
+complete -a unalias
+complete -g groupdel
+complete -A hostname telnet
+complete -v -S '=' declare
+complete -v -S '=' export
+complete -v -S '=' local
+complete -v -S '=' readonly
+complete -o bashdefault -o filenames -o nospace -F _comp_cd cd
+complete -f -X '!*.dvi' xdvi
+complete -c type
+complete -f ln
+complete -f -X '!*.+(gz|tgz)' gunzip
+complete -f -X '!*.texi*' makeinfo
+complete -u su
+complete -j -P '%' jobs
+complete -o dirnames -o filenames -o nospace -d popd
+complete -A signal trap
+complete -o dirnames -o filenames -o nospace -d pushd
+complete -f -X '!*.pdf' acroread
+complete -v unset
+complete -f -X '!*.+(ps|PS)' ghostview
+complete -j -W '$(ps -x | tail +2 | cut -c1-5)' -P '%' wait
+complete -A hostname rsh
+complete -c exec
+complete -f -X '!*.Z' zmore
+complete -A signal kill
+complete -j -P '%' disown
+complete -f -X '!*.+(ps|PS)' gs
+complete -f -X '!*.+(ps|PS)' gv
+complete -f source
+complete -c make
+complete -A stopped -P '%' bg
+complete -f cat
+complete -d mkdir
+complete -A helptopic help
+complete -c eval
+complete -f chown
+complete -v read
+complete -c -k time
+complete -f -X '!*.Z' zcat
+complete -f gzip
+complete -W '"${GROUPS[@]}"' newgrp
+complete -f -X '!*.Z' uncompress
+complete -d rmdir
+complete -A shopt shopt
+complete -A hostname ftp
+complete -f more
+complete -A hostname rlogin
+complete -v getopts
+complete -f -X '!*.+(gz|tgz)' gzcat
+./complete.tests: line 123: complete: notthere: no completion specification
diff --git a/tests/complete.tests b/tests/complete.tests
new file mode 100644
index 00000000..36a39833
--- /dev/null
+++ b/tests/complete.tests
@@ -0,0 +1,126 @@
+# Chet Ramey <chet.ramey@case.edu>
+#
+# Copyright 2002-2020 Chester Ramey
+#
+# 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 2, or (at your option)
+# any later version.
+#
+# TThis 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, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+complete
+
+# from zsh, just for testing
+complete -A stopped -P '%' bg
+complete -j -P '%' fg jobs disown
+# this is wrong at this point
+complete -j -P '%' -W '$(ps -x | tail +2 | cut -c1-5)' wait
+complete -c type
+complete -a unalias
+complete -v getopts read unset
+complete -v -S '=' declare export local readonly typeset
+complete -f -- . source
+complete -A shopt shopt
+complete -e printenv
+
+complete -A helptopic help
+
+complete -c nohup exec nice eval
+complete -c -k time
+
+complete -A signal trap kill
+
+complete -f chown ln more cat
+complete -d mkdir rmdir
+
+complete -f -X '!*.+(gz|tgz)' gunzip gzcat zcat zmore
+complete -f -X '!*.Z' uncompress zmore zcat
+complete -f gzip
+
+complete -o dirnames -o filenames -o nospace -d pushd popd
+
+_comp_cd()
+{
+ local IFS=$' \t\n' # normalize IFS
+ local cur _skipdot _cdpath
+ local i j k
+
+ # Tilde expansion, with side effect of expanding tilde to full pathname
+ case "$2" in
+ \~*) eval cur="$2" ;;
+ *) cur=$2 ;;
+ esac
+
+ # no cdpath or absolute pathname -- straight directory completion
+ if [[ -z "${CDPATH:-}" ]] || [[ "$cur" == @(./*|../*|/*) ]]; then
+ # compgen prints paths one per line; could also use while loop
+ IFS=$'\n'
+ COMPREPLY=( $(compgen -d -- "$cur") )
+ IFS=$' \t\n'
+ # CDPATH+directories in the current directory if not in CDPATH
+ else
+ IFS=$'\n'
+ _skipdot=false
+ # preprocess CDPATH to convert null directory names to .
+ _cdpath=${CDPATH/#:/.:}
+ _cdpath=${_cdpath//::/:.:}
+ _cdpath=${_cdpath/%:/:.}
+ for i in ${_cdpath//:/$'\n'}; do
+ if [[ $i -ef . ]]; then _skipdot=true; fi
+ k="${#COMPREPLY[@]}"
+ for j in $( compgen -d -- "$i/$cur" ); do
+ COMPREPLY[k++]=${j#$i/} # cut off directory
+ done
+ done
+ $_skipdot || COMPREPLY+=( $(compgen -d -- "$cur") )
+ IFS=$' \t\n'
+ fi
+
+ # variable names if appropriate shell option set and no completions
+ if shopt -q cdable_vars && [[ ${#COMPREPLY[@]} -eq 0 ]]; then
+ COMPREPLY=( $(compgen -v -- "$cur") )
+ fi
+
+ # append slash to passed directory name that is the only completion.
+ # readline will not do this if we complete from CDPATH
+ if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
+ i=${COMPREPLY[0]} # shorthand
+ if [[ "$cur" == "$i" ]] && [[ "$i" != "*/" ]]; then
+ COMPREPLY[0]+=/
+ fi
+ fi
+ return 0
+}
+
+complete -o filenames -o nospace -o bashdefault -F _comp_cd cd
+
+complete -A hostname rsh telnet rlogin ftp
+
+complete -u su
+complete -W '"${GROUPS[@]}"' newgrp
+complete -g groupdel groupmod
+
+complete -f -X '!*.+(ps|PS)' gs gv ghostview
+complete -f -X '!*.dvi' dvips xdvi
+complete -f -X '!*.pdf' acroread
+
+complete -f -X '!*.texi*' makeinfo texi2dvi texi2html
+
+complete -c gdb make
+
+complete -p gs
+complete -p
+
+complete -r xdvi
+complete -r notthere
+
+complete -r
+complete
diff --git a/tests/comsub-eof.right b/tests/comsub-eof.right
index 452a9c5f..42677985 100644
--- a/tests/comsub-eof.right
+++ b/tests/comsub-eof.right
@@ -11,3 +11,5 @@ contents
hi
./comsub-eof5.sub: line 13: warning: here-document at line 11 delimited by end-of-file (wanted `EOF')
hi
+./comsub-eof6.sub: line 1: unexpected EOF while looking for matching `)'
+
diff --git a/tests/comsub-eof.tests b/tests/comsub-eof.tests
index f96aeee9..398746aa 100644
--- a/tests/comsub-eof.tests
+++ b/tests/comsub-eof.tests
@@ -9,3 +9,5 @@ ${THIS_SH} ./comsub-eof3.sub
${THIS_SH} ./comsub-eof4.sub
${THIS_SH} ./comsub-eof5.sub
+
+${THIS_SH} ./comsub-eof6.sub
diff --git a/tests/comsub-eof6.sub b/tests/comsub-eof6.sub
new file mode 100644
index 00000000..c0e63ddd
--- /dev/null
+++ b/tests/comsub-eof6.sub
@@ -0,0 +1,5 @@
+read foo <<EOF
+$(seq 10
+EOF
+
+echo "$foo"
diff --git a/tests/comsub-posix.right b/tests/comsub-posix.right
index 2290aa6d..9aebb848 100644
--- a/tests/comsub-posix.right
+++ b/tests/comsub-posix.right
@@ -4,6 +4,7 @@ ab
abcd
+abcd
sh_352.26ax
sh_352.26ay
sh_352.25a sh_352.25b
@@ -47,11 +48,14 @@ after 5
after 6
x
x
+x
quoted )
comment
here-doc with )
+here-doc with \()
here-doc terminated with a parenthesis
' # or a single back- or doublequote
+line terminated with a backslash
./comsub-posix1.sub: command substitution: line 2: syntax error near unexpected token `)'
./comsub-posix1.sub: command substitution: line 2: ` if x; then echo foo )'
after
diff --git a/tests/comsub-posix.tests b/tests/comsub-posix.tests
index d53e6ebc..4fe1dfaa 100644
--- a/tests/comsub-posix.tests
+++ b/tests/comsub-posix.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${HOME:=/}
# works right
@@ -14,6 +27,7 @@ echo $(
)
echo $()
echo ab$()cd
+echo ab$( )cd
echo $(case a in (a) echo sh_352.26ax; esac )
echo $(case a in (a) echo sh_352.26ay; esac)
@@ -168,6 +182,10 @@ echo $(
)
echo $(
+ case x in x) echo x;; esac # followed by a comment
+)
+
+echo $(
case x in (x) echo x;; esac
)
@@ -186,6 +204,12 @@ eof
)
echo $(
+ cat <<\eof
+ here-doc with \()
+eof
+)
+
+echo $(
cat <<\)
here-doc terminated with a parenthesis
)
@@ -197,6 +221,10 @@ cat <<\eof
eof
)
+echo $(
+ echo line terminated with a backslash # \
+)
+
${THIS_SH} ./comsub-posix1.sub
${THIS_SH} ./comsub-posix2.sub
diff --git a/tests/comsub-posix2.sub b/tests/comsub-posix2.sub
index 238745f7..d556fa93 100644
--- a/tests/comsub-posix2.sub
+++ b/tests/comsub-posix2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# problem with bash-4.x versions before bash-4.2. required posix interp
swap32_posix()
{
diff --git a/tests/comsub-posix3.sub b/tests/comsub-posix3.sub
index 3a0e39a8..39262b22 100644
--- a/tests/comsub-posix3.sub
+++ b/tests/comsub-posix3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# parsing errors before bash-4.2
a=$(/bin/cat << EOF | wc -l
diff --git a/tests/comsub.right b/tests/comsub.right
index 71bb205a..a329c832 100644
--- a/tests/comsub.right
+++ b/tests/comsub.right
@@ -1,4 +1,4 @@
-./comsub.tests: line 7: hijkl: command not found
+./comsub.tests: line 20: hijkl: command not found
argv[1] = <ab>
argv[2] = <cd>
argv[1] = <abmn>
diff --git a/tests/comsub.tests b/tests/comsub.tests
index ed56007c..47863024 100644
--- a/tests/comsub.tests
+++ b/tests/comsub.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# command substution parsing tests
TABSIZE=`grep -v '^[ #]' $CAPS </dev/null | grep -v "^$" | grep -v "^capalias"| grep -v "^infoalias" | wc -l`
diff --git a/tests/comsub1.sub b/tests/comsub1.sub
index b1af263b..ca722439 100644
--- a/tests/comsub1.sub
+++ b/tests/comsub1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: $(echo \;)
: $(case a in a) echo ;;# comment
diff --git a/tests/comsub3.sub b/tests/comsub3.sub
index 69474000..757fbcae 100644
--- a/tests/comsub3.sub
+++ b/tests/comsub3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
x=$(
case 1 in
1) echo 1
diff --git a/tests/comsub4.sub b/tests/comsub4.sub
index 461a9ad1..e7a1c557 100644
--- a/tests/comsub4.sub
+++ b/tests/comsub4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
x=$(cat <<'EOT'
d \
g
diff --git a/tests/cond-regexp1.sub b/tests/cond-regexp1.sub
index dd287cbc..1ba9197a 100644
--- a/tests/cond-regexp1.sub
+++ b/tests/cond-regexp1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
VAR='[[:alpha:]]'
[[ $VAR =~ '[[:alpha:]]' ]] && echo match 1
diff --git a/tests/cond-regexp2.sub b/tests/cond-regexp2.sub
index 2bea6384..4da0a88f 100644
--- a/tests/cond-regexp2.sub
+++ b/tests/cond-regexp2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
[[ "\\" =~ ["."] ]] && echo bad 1
[[ "\\" =~ "[.]" ]] && echo bad 2
diff --git a/tests/cond-regexp3.sub b/tests/cond-regexp3.sub
index 8f098416..d939548c 100644
--- a/tests/cond-regexp3.sub
+++ b/tests/cond-regexp3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# simple expansion -- no problem, it's quote_string_for_globbing that was flawed
c=$'\177'
r="\\$c"
diff --git a/tests/cond.right b/tests/cond.right
index 18ebd060..59a4a886 100644
--- a/tests/cond.right
+++ b/tests/cond.right
@@ -23,7 +23,7 @@ returns: 0
returns: 1
returns: 1
returns: 0
-./cond.tests: line 101: [[: 4+: syntax error: operand expected (error token is "+")
+./cond.tests: line 114: [[: 4+: syntax error: operand expected (error token is "+")
returns: 1
returns: 0
returns: 0
diff --git a/tests/cond.tests b/tests/cond.tests
index 2cef9293..aa6a8104 100755..100644
--- a/tests/cond.tests
+++ b/tests/cond.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
#
# the test/[ code is tested elsewhere, and the [[...]] just uses the same
# code. this tests the special features of [[...]]
diff --git a/tests/coproc.tests b/tests/coproc.tests
index 5066f7c5..a7359320 100644
--- a/tests/coproc.tests
+++ b/tests/coproc.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${TMPDIR:=/tmp}
TMPOUT=${TMPDIR}/coproc-wait-$BASHPID
diff --git a/tests/cprint.tests b/tests/cprint.tests
index 08ff1ebc..e598f8c9 100644
--- a/tests/cprint.tests
+++ b/tests/cprint.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
#
# a nonsense script and shell function to test out the command printing code
#
diff --git a/tests/dbg-support.right b/tests/dbg-support.right
index c4a1609e..6e2194aa 100644
--- a/tests/dbg-support.right
+++ b/tests/dbg-support.right
@@ -1,357 +1,357 @@
-debug lineno: 63 main
-debug lineno: 66 main
+debug lineno: 74 main
+debug lineno: 77 main
FUNCNAME main
-debug lineno: 70 main
-debug lineno: 17 fn1
-debug lineno: 18 fn1
-LINENO 18
-debug lineno: 19 fn1
-LINENO 19
-debug lineno: 20 fn1
+debug lineno: 81 main
+debug lineno: 30 fn1
+debug lineno: 31 fn1
+LINENO 31
+debug lineno: 32 fn1
+LINENO 32
+debug lineno: 33 fn1
BASH_SOURCE[0] ./dbg-support.tests
-debug lineno: 21 fn1
+debug lineno: 34 fn1
FUNCNAME[0] fn1
-debug lineno: 22 fn1
-debug lineno: 22 fn1 70 ./dbg-support.tests
-debug lineno: 23 fn1
-debug lineno: 23 fn1 70 main ./dbg-support.tests
-debug lineno: 24 fn1
-debug lineno: 24 fn1
-debug lineno: 25 fn1
-./dbg-support.tests: line 25: caller: foo: invalid number
+debug lineno: 35 fn1
+debug lineno: 35 fn1 81 ./dbg-support.tests
+debug lineno: 36 fn1
+debug lineno: 36 fn1 81 main ./dbg-support.tests
+debug lineno: 37 fn1
+debug lineno: 37 fn1
+debug lineno: 38 fn1
+./dbg-support.tests: line 38: caller: foo: invalid number
caller: usage: caller [expr]
-debug lineno: 25 fn1
-debug lineno: 17 fn1
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
-return lineno: 17 fn1
-debug lineno: 14 print_return_trap
-debug lineno: 71 main
-debug lineno: 28 fn2
-debug lineno: 29 fn2
+debug lineno: 38 fn1
+debug lineno: 30 fn1
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
+return lineno: 30 fn1
+debug lineno: 27 print_return_trap
+debug lineno: 82 main
+debug lineno: 41 fn2
+debug lineno: 42 fn2
fn2 here. Calling fn1...
-debug lineno: 30 fn2
-debug lineno: 17 fn1
-debug lineno: 18 fn1
-LINENO 18
-debug lineno: 19 fn1
-LINENO 19
-debug lineno: 20 fn1
+debug lineno: 43 fn2
+debug lineno: 30 fn1
+debug lineno: 31 fn1
+LINENO 31
+debug lineno: 32 fn1
+LINENO 32
+debug lineno: 33 fn1
BASH_SOURCE[0] ./dbg-support.tests
-debug lineno: 21 fn1
+debug lineno: 34 fn1
FUNCNAME[0] fn1
-debug lineno: 22 fn1
-debug lineno: 22 fn1 30 ./dbg-support.tests
-debug lineno: 23 fn1
-debug lineno: 23 fn1 30 fn2 ./dbg-support.tests
-debug lineno: 24 fn1
-debug lineno: 24 fn1 71 main ./dbg-support.tests
-debug lineno: 25 fn1
-./dbg-support.tests: line 25: caller: foo: invalid number
+debug lineno: 35 fn1
+debug lineno: 35 fn1 43 ./dbg-support.tests
+debug lineno: 36 fn1
+debug lineno: 36 fn1 43 fn2 ./dbg-support.tests
+debug lineno: 37 fn1
+debug lineno: 37 fn1 82 main ./dbg-support.tests
+debug lineno: 38 fn1
+./dbg-support.tests: line 38: caller: foo: invalid number
caller: usage: caller [expr]
-debug lineno: 25 fn1
-debug lineno: 17 fn1
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
-return lineno: 17 fn1
-debug lineno: 14 print_return_trap
-debug lineno: 28 fn2
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
-return lineno: 28 fn2
-debug lineno: 14 print_return_trap
-debug lineno: 72 main
-debug lineno: 33 fn3
-debug lineno: 34 fn3
-LINENO 34
-debug lineno: 35 fn3
+debug lineno: 38 fn1
+debug lineno: 30 fn1
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
+return lineno: 30 fn1
+debug lineno: 27 print_return_trap
+debug lineno: 41 fn2
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
+return lineno: 41 fn2
+debug lineno: 27 print_return_trap
+debug lineno: 83 main
+debug lineno: 46 fn3
+debug lineno: 47 fn3
+LINENO 47
+debug lineno: 48 fn3
BASH_SOURCE[0] ./dbg-support.tests
-debug lineno: 38 fn3
-debug lineno: 39 fn3
-debug lineno: 40 fn3
-debug lineno: 40 fn3
-debug lineno: 41 fn3
-debug lineno: 42 fn3
-debug lineno: 43 fn3
+debug lineno: 51 fn3
+debug lineno: 52 fn3
+debug lineno: 53 fn3
+debug lineno: 53 fn3
+debug lineno: 54 fn3
+debug lineno: 55 fn3
+debug lineno: 56 fn3
fn3 called from file `./dbg-support.tests' at line 0
-debug lineno: 40 fn3
-debug lineno: 40 fn3
-debug lineno: 41 fn3
-debug lineno: 42 fn3
-debug lineno: 42 fn3
-debug lineno: 43 fn3
+debug lineno: 53 fn3
+debug lineno: 53 fn3
+debug lineno: 54 fn3
+debug lineno: 55 fn3
+debug lineno: 55 fn3
+debug lineno: 56 fn3
main called from file `./dbg-support.tests' at line 0
-debug lineno: 40 fn3
-debug lineno: 40 fn3
-debug lineno: 46 fn3
-debug lineno: 18 source
-SOURCED LINENO 18
-debug lineno: 19 source
+debug lineno: 53 fn3
+debug lineno: 53 fn3
+debug lineno: 59 fn3
+debug lineno: 31 source
+SOURCED LINENO 31
+debug lineno: 32 source
SOURCED BASH_SOURCE[0] ./dbg-support.sub
-debug lineno: 20 source
-debug lineno: 3 sourced_fn
-debug lineno: 4 sourced_fn
-debug lineno: 5 sourced_fn
-SOURCED FN LINENO 5
-debug lineno: 8 sourced_fn
-debug lineno: 9 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
-FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
-FUNCNAME[1]: source called from ./dbg-support.tests at line 46
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
-FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 72
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
+debug lineno: 33 source
+debug lineno: 16 sourced_fn
+debug lineno: 17 sourced_fn
+debug lineno: 18 sourced_fn
+SOURCED FN LINENO 18
+debug lineno: 21 sourced_fn
+debug lineno: 22 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
+FUNCNAME[1]: source called from ./dbg-support.tests at line 59
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
+FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 83
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
FUNCNAME[3]: main called from ./dbg-support.tests at line 0
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 3 sourced_fn
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
-return lineno: 3 sourced_fn
-debug lineno: 14 print_return_trap
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 16 sourced_fn
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
+return lineno: 16 sourced_fn
+debug lineno: 27 print_return_trap
+debug lineno: 59 fn3
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
+return lineno: 59 fn3
+debug lineno: 27 print_return_trap
debug lineno: 46 fn3
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
return lineno: 46 fn3
-debug lineno: 14 print_return_trap
-debug lineno: 33 fn3
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
-return lineno: 33 fn3
-debug lineno: 14 print_return_trap
-debug lineno: 73 main
-debug lineno: 18 source
-SOURCED LINENO 18
-debug lineno: 19 source
+debug lineno: 27 print_return_trap
+debug lineno: 84 main
+debug lineno: 31 source
+SOURCED LINENO 31
+debug lineno: 32 source
SOURCED BASH_SOURCE[0] ./dbg-support.sub
-debug lineno: 20 source
-debug lineno: 3 sourced_fn
-debug lineno: 4 sourced_fn
-debug lineno: 5 sourced_fn
-SOURCED FN LINENO 5
-debug lineno: 8 sourced_fn
-debug lineno: 9 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
-FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
-FUNCNAME[1]: source called from ./dbg-support.tests at line 73
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
+debug lineno: 33 source
+debug lineno: 16 sourced_fn
+debug lineno: 17 sourced_fn
+debug lineno: 18 sourced_fn
+SOURCED FN LINENO 18
+debug lineno: 21 sourced_fn
+debug lineno: 22 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
+FUNCNAME[1]: source called from ./dbg-support.tests at line 84
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
FUNCNAME[2]: main called from ./dbg-support.tests at line 0
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 3 sourced_fn
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
-return lineno: 3 sourced_fn
-debug lineno: 14 print_return_trap
-debug lineno: 73 main
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
-return lineno: 73 main
-debug lineno: 14 print_return_trap
-debug lineno: 76 main
-debug lineno: 79 main
-LINENO 18
-LINENO 19
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 16 sourced_fn
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
+return lineno: 16 sourced_fn
+debug lineno: 27 print_return_trap
+debug lineno: 84 main
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
+return lineno: 84 main
+debug lineno: 27 print_return_trap
+debug lineno: 87 main
+debug lineno: 90 main
+LINENO 31
+LINENO 32
BASH_SOURCE[0] ./dbg-support.tests
FUNCNAME[0] fn1
-79 ./dbg-support.tests
-79 main ./dbg-support.tests
+90 ./dbg-support.tests
+90 main ./dbg-support.tests
-./dbg-support.tests: line 25: caller: foo: invalid number
+./dbg-support.tests: line 38: caller: foo: invalid number
caller: usage: caller [expr]
-debug lineno: 80 main
+debug lineno: 91 main
fn2 here. Calling fn1...
-LINENO 18
-LINENO 19
+LINENO 31
+LINENO 32
BASH_SOURCE[0] ./dbg-support.tests
FUNCNAME[0] fn1
-30 ./dbg-support.tests
-30 fn2 ./dbg-support.tests
-80 main ./dbg-support.tests
-./dbg-support.tests: line 25: caller: foo: invalid number
+43 ./dbg-support.tests
+43 fn2 ./dbg-support.tests
+91 main ./dbg-support.tests
+./dbg-support.tests: line 38: caller: foo: invalid number
caller: usage: caller [expr]
-debug lineno: 81 main
-LINENO 34
+debug lineno: 92 main
+LINENO 47
BASH_SOURCE[0] ./dbg-support.tests
fn3 called from file `./dbg-support.tests' at line 0
main called from file `./dbg-support.tests' at line 0
-SOURCED LINENO 18
+SOURCED LINENO 31
SOURCED BASH_SOURCE[0] ./dbg-support.sub
-SOURCED FN LINENO 5
-FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
-FUNCNAME[1]: source called from ./dbg-support.tests at line 46
-FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 81
+SOURCED FN LINENO 18
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
+FUNCNAME[1]: source called from ./dbg-support.tests at line 59
+FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 92
FUNCNAME[3]: main called from ./dbg-support.tests at line 0
-debug lineno: 82 main
+debug lineno: 93 main
fn4 here. Calling fn3...
-LINENO 34
+LINENO 47
BASH_SOURCE[0] ./dbg-support.tests
-fn3 called from file `./dbg-support.tests' at line 82
+fn3 called from file `./dbg-support.tests' at line 93
fn4 called from file `./dbg-support.tests' at line 0
main called from file `./dbg-support.tests' at line 0
-SOURCED LINENO 18
+SOURCED LINENO 31
SOURCED BASH_SOURCE[0] ./dbg-support.sub
-SOURCED FN LINENO 5
-FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
-FUNCNAME[1]: source called from ./dbg-support.tests at line 46
-FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 51
-FUNCNAME[3]: fn4 called from ./dbg-support.tests at line 82
+SOURCED FN LINENO 18
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
+FUNCNAME[1]: source called from ./dbg-support.tests at line 59
+FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 64
+FUNCNAME[3]: fn4 called from ./dbg-support.tests at line 93
FUNCNAME[4]: main called from ./dbg-support.tests at line 0
-debug lineno: 83 main
-SOURCED LINENO 18
+debug lineno: 94 main
+SOURCED LINENO 31
SOURCED BASH_SOURCE[0] ./dbg-support.sub
-SOURCED FN LINENO 5
-FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
-FUNCNAME[1]: source called from ./dbg-support.tests at line 83
+SOURCED FN LINENO 18
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
+FUNCNAME[1]: source called from ./dbg-support.tests at line 94
FUNCNAME[2]: main called from ./dbg-support.tests at line 0
-return lineno: 83 main
-debug lineno: 86 main
-debug lineno: 89 main
-debug lineno: 18 source
-SOURCED LINENO 18
-debug lineno: 19 source
+return lineno: 94 main
+debug lineno: 97 main
+debug lineno: 100 main
+debug lineno: 31 source
+SOURCED LINENO 31
+debug lineno: 32 source
SOURCED BASH_SOURCE[0] ./dbg-support.sub
-debug lineno: 20 source
-debug lineno: 3 sourced_fn
-debug lineno: 4 sourced_fn
-debug lineno: 5 sourced_fn
-SOURCED FN LINENO 5
-debug lineno: 8 sourced_fn
-debug lineno: 9 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
-FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 20
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
-FUNCNAME[1]: source called from ./dbg-support.tests at line 89
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
+debug lineno: 33 source
+debug lineno: 16 sourced_fn
+debug lineno: 17 sourced_fn
+debug lineno: 18 sourced_fn
+SOURCED FN LINENO 18
+debug lineno: 21 sourced_fn
+debug lineno: 22 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
+FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
+FUNCNAME[1]: source called from ./dbg-support.tests at line 100
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
FUNCNAME[2]: main called from ./dbg-support.tests at line 0
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 3 sourced_fn
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
-return lineno: 3 sourced_fn
-debug lineno: 14 print_return_trap
-debug lineno: 89 main
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
-return lineno: 89 main
-debug lineno: 14 print_return_trap
-debug lineno: 90 main
-debug lineno: 93 main
-debug lineno: 93 main
-debug lineno: 94 main
-debug lineno: 97 main
-debug lineno: 93 main
-debug lineno: 93 main
-debug lineno: 94 main
-debug lineno: 97 main
-debug lineno: 93 main
-debug lineno: 93 main
-debug lineno: 94 main
-debug lineno: 95 main
-Hit 2
-debug lineno: 97 main
-debug lineno: 93 main
-debug lineno: 93 main
-debug lineno: 103 main
-SOURCED FN LINENO 5 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 103 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 16 sourced_fn
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
+return lineno: 16 sourced_fn
+debug lineno: 27 print_return_trap
+debug lineno: 100 main
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
+return lineno: 100 main
+debug lineno: 27 print_return_trap
+debug lineno: 101 main
+debug lineno: 104 main
+debug lineno: 104 main
+debug lineno: 105 main
+debug lineno: 108 main
+debug lineno: 104 main
+debug lineno: 104 main
+debug lineno: 105 main
+debug lineno: 108 main
+debug lineno: 104 main
debug lineno: 104 main
-SOURCED FN LINENO 5 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 104 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
debug lineno: 105 main
debug lineno: 106 main
-SOURCED FN LINENO 5
-FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 106
+Hit 2
+debug lineno: 108 main
+debug lineno: 104 main
+debug lineno: 104 main
+debug lineno: 114 main
+SOURCED FN LINENO 18 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 114 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
+debug lineno: 115 main
+SOURCED FN LINENO 18 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 115 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
+debug lineno: 116 main
+debug lineno: 117 main
+SOURCED FN LINENO 18
+FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 117
FUNCNAME[1]: main called from ./dbg-support.tests at line 0
-debug lineno: 110 main
-debug lineno: 111 main
-debug lineno: 3 sourced_fn
-debug lineno: 4 sourced_fn
-debug lineno: 5 sourced_fn
-SOURCED FN LINENO 5
-debug lineno: 8 sourced_fn
-debug lineno: 9 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
-FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 111
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 11 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 12 sourced_fn
-debug lineno: 13 sourced_fn
+debug lineno: 121 main
+debug lineno: 122 main
+debug lineno: 16 sourced_fn
+debug lineno: 17 sourced_fn
+debug lineno: 18 sourced_fn
+SOURCED FN LINENO 18
+debug lineno: 21 sourced_fn
+debug lineno: 22 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
+FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 122
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 24 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 25 sourced_fn
+debug lineno: 26 sourced_fn
FUNCNAME[1]: main called from ./dbg-support.tests at line 0
-debug lineno: 10 sourced_fn
-debug lineno: 10 sourced_fn
-debug lineno: 3 sourced_fn
-debug lineno: 12 print_return_trap
-debug lineno: 13 print_return_trap
-return lineno: 3 sourced_fn
-debug lineno: 14 print_return_trap
-debug lineno: 114 main
-debug lineno: 119 main
-debug lineno: 123 main
+debug lineno: 23 sourced_fn
+debug lineno: 23 sourced_fn
+debug lineno: 16 sourced_fn
+debug lineno: 25 print_return_trap
+debug lineno: 26 print_return_trap
+return lineno: 16 sourced_fn
+debug lineno: 27 print_return_trap
+debug lineno: 125 main
+debug lineno: 130 main
+debug lineno: 134 main
got it
-debug lineno: 131 main
-debug lineno: 132 main
-debug lineno: 133 main
-debug lineno: 132 main
-debug lineno: 133 main
-debug lineno: 131 main
-debug lineno: 132 main
-debug lineno: 133 main
-debug lineno: 132 main
-debug lineno: 133 main
-debug lineno: 137 main
+debug lineno: 142 main
+debug lineno: 143 main
+debug lineno: 144 main
+debug lineno: 143 main
+debug lineno: 144 main
+debug lineno: 142 main
+debug lineno: 143 main
+debug lineno: 144 main
+debug lineno: 143 main
+debug lineno: 144 main
+debug lineno: 148 main
main: calling f1
f1: calling f2
f2: calling f3
@@ -364,7 +364,7 @@ deep 6
4 x
5 1
FUNCNAME stack: f3 f2 f1 main
-26 f2 ./dbg-support3.sub
+39 f2 ./dbg-support3.sub
f3: returning
f2: return from f3
f1: return from f2
diff --git a/tests/dbg-support.sub b/tests/dbg-support.sub
index f68f8d9b..8c82c80c 100644
--- a/tests/dbg-support.sub
+++ b/tests/dbg-support.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# This file is intended to be sourced from one of the bashdb test programs
sourced_fn() {
diff --git a/tests/dbg-support.tests b/tests/dbg-support.tests
index ad06d011..b4a58e4b 100755..100644
--- a/tests/dbg-support.tests
+++ b/tests/dbg-support.tests
@@ -1,4 +1,17 @@
-#!../bash
+# 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 correct functioning bash debug support not via the bashdb
# debugger but merely by printing via print_trap()
@@ -51,8 +64,6 @@ fn4() {
fn3
}
-
-#!../bash
#
# Test of support for debugging facilities in bash
#
@@ -105,7 +116,7 @@ echo `sourced_fn`
x=$((sourced_fn))
x={ sourced_fn }
-# Make sure we step into sourced_fn as a comand when we request to do so.
+# Make sure we step into sourced_fn as a command when we request to do so.
# Vanilla bash 2.0 doesn't do.
set -o functrace
x={ sourced_fn }
@@ -135,8 +146,3 @@ for i in 0 1 ; do
done
${THIS_SH} ./dbg-support3.sub
-
-#;;; Local Variables: ***
-#;;; mode:shell-script ***
-#;;; eval: (sh-set-shell "bash") ***
-#;;; End: ***
diff --git a/tests/dbg-support2.right b/tests/dbg-support2.right
index c9d884e6..5727d1f1 100644
--- a/tests/dbg-support2.right
+++ b/tests/dbg-support2.right
@@ -1,7 +1,7 @@
-lineno: 17 (6) main
-lineno: 18 (6) main
+lineno: 29 (18) main
+lineno: 30 (18) main
x is 1
-lineno: 19 (6) main
-lineno: 20 (6) main
-lineno: 21 (6) main
+lineno: 31 (18) main
+lineno: 32 (18) main
+lineno: 33 (18) main
x is 1
diff --git a/tests/dbg-support2.tests b/tests/dbg-support2.tests
index fdc0f31e..c33251d3 100755..100644
--- a/tests/dbg-support2.tests
+++ b/tests/dbg-support2.tests
@@ -1,4 +1,16 @@
-#!../bash
+# 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 correct trap return codes = 2 means skip execution.
shopt -s extdebug
@@ -19,8 +31,3 @@ echo "x is $x"
debug_exit=2
x=2
echo "x is $x"
-
-#;;; Local Variables: ***
-#;;; mode:shell-script ***
-#;;; eval: (sh-set-shell "bash") ***
-#;;; End: ***
diff --git a/tests/dbg-support3.sub b/tests/dbg-support3.sub
index cc52c654..146831f4 100644
--- a/tests/dbg-support3.sub
+++ b/tests/dbg-support3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
shopt -s extdebug
callstack(){
diff --git a/tests/dollar-at-star b/tests/dollar-at-star
index 0f713dc3..d4808989 100755
--- a/tests/dollar-at-star
+++ b/tests/dollar-at-star
@@ -242,6 +242,10 @@ ${THIS_SH} ./dollar-at-star7.sub
# members separated by spaces
${THIS_SH} ./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
+
# tests for special expansion of "$*" and "${array[*]}" when used with other
# expansions -- bugs through bash-2.05b
${THIS_SH} ./dollar-star1.sub
@@ -302,4 +306,8 @@ ${THIS_SH} ./dollar-at7.sub
# IFS is null
${THIS_SH} ./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
+
exit 0
diff --git a/tests/dollar-at-star1.sub b/tests/dollar-at-star1.sub
index 0036915b..ef15efc3 100644
--- a/tests/dollar-at-star1.sub
+++ b/tests/dollar-at-star1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# from dan douglas
expassign()
{
diff --git a/tests/dollar-at-star2.sub b/tests/dollar-at-star2.sub
index 780548ed..64ab1eb7 100644
--- a/tests/dollar-at-star2.sub
+++ b/tests/dollar-at-star2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
OIFS="$IFS"
foo=' ,foo'
set -- "$foo"
diff --git a/tests/dollar-at-star3.sub b/tests/dollar-at-star3.sub
index b37d64af..da05444b 100644
--- a/tests/dollar-at-star3.sub
+++ b/tests/dollar-at-star3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
unset f ; f=abcd
first_char=${f[@]:0:1}
diff --git a/tests/dollar-at-star4.sub b/tests/dollar-at-star4.sub
index be2892dd..9f7da8e8 100644
--- a/tests/dollar-at-star4.sub
+++ b/tests/dollar-at-star4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# tests for quoted and unquoted, split and unsplit expansions of $@ and $*
# Posix interpretation 221 speaks to this issue
diff --git a/tests/dollar-at-star5.sub b/tests/dollar-at-star5.sub
index 3bd7b0f8..d07c61a0 100644
--- a/tests/dollar-at-star5.sub
+++ b/tests/dollar-at-star5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# testing various combinations of quoted and unquoted expansions of $@, and
# whether they generate empty words after expansion
diff --git a/tests/dollar-at-star6.sub b/tests/dollar-at-star6.sub
index 7366df50..09353b8c 100644
--- a/tests/dollar-at-star6.sub
+++ b/tests/dollar-at-star6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
OIFS="$IFS"
arr=(a b c)
diff --git a/tests/dollar-at-star7.sub b/tests/dollar-at-star7.sub
index 47cb37f6..e4e63b7b 100644
--- a/tests/dollar-at-star7.sub
+++ b/tests/dollar-at-star7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
IFS='' # testing with only empty IFS
set -- this is a test
diff --git a/tests/dollar-at-star9.sub b/tests/dollar-at-star9.sub
new file mode 100644
index 00000000..e5062f79
--- /dev/null
+++ b/tests/dollar-at-star9.sub
@@ -0,0 +1,278 @@
+# 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/>.
+#
+IFS=$' \t\n' # or any other IFS
+set -- ''
+recho ${v= "$*" }
+recho "$v"
+unset -v v
+
+IFS=''
+set -- '' ''
+recho ${v= "$*" }
+recho "$v"
+unset -v v
+
+IFS=$' \t\n' # or any other IFS
+unset -v v
+
+set -- ''
+recho ${v= "$@" }
+recho "$v"
+unset v
+recho ${v= $@ }
+recho "$v"
+unset v
+recho ${v= $@"" }
+recho "$v"
+unset v
+recho ${v= ${@} }
+recho "$v"
+unset v
+recho ${v= ${@}"" }
+recho "$v"
+unset v
+
+set -- '' ''
+recho ${v= $@ }
+recho "$v"
+unset v
+recho ${v= "$@" }
+recho "$v"
+unset v
+recho "${v= $@}"
+recho "$v"
+unset v
+recho ${v= "$@"}
+recho "$v"
+unset v
+
+IFS=
+
+set -- X
+X=X
+
+recho ${0+ "$@" }
+recho ${0+ $@ }
+recho ${0+ $* }
+
+recho ${0+ "$X" }
+recho ${0+ $X }
+recho ${0+ $X }
+
+recho ${0+ "$@" }
+recho "$Y"
+unset Y
+recho ${0+ $@ }
+recho "$Y"
+unset Y
+recho ${0+ $* }
+recho "$Y"
+unset Y
+
+recho ${Y:= "$X" }
+recho "$Y"
+unset Y
+recho ${Y:= $X }
+recho "$Y"
+unset Y
+recho ${Y:= $X }
+recho "$Y"
+unset Y
+
+IFS=
+
+unset -v X Y
+
+set -- X Y
+X='X Y'
+
+recho ${0+ "$@" }
+recho ${0+ $@ }
+recho ${0+ $* }
+
+recho ${0+ "$X" }
+recho ${0+ $X }
+recho ${0+ $X }
+
+recho ${Y:= "$@" }
+recho "$Y"
+unset Y
+recho ${Y:= $@ }
+recho "$Y"
+unset Y
+recho ${Y:= $* }
+recho "$Y"
+unset Y
+
+recho ${Y:= "$X" }
+recho "$Y"
+unset Y
+recho ${Y:= $X }
+recho "$Y"
+unset Y
+recho ${Y:= $X }
+recho "$Y"
+unset Y
+
+IFS=''
+set -- ' X '
+
+unset x y
+
+x=$*
+y=${*:1}
+
+recho "$x"
+recho "$y"
+
+unset x y
+
+recho ${x=$*}
+recho ${y=${*:1}}
+
+set -- b a
+declare -A A=([b]= [a]=)
+
+x=$*
+y=${!A[*]}
+
+unset A
+
+recho "$x"
+recho "$y"
+
+unset x y
+
+recho ${x=$*}
+recho ${y=${!A[*]}}
+
+unset x y
+
+recho ${x-$*}
+recho ${y-${!A[*]}} # this isn't right yet
+
+IFS=:
+set -- a b
+ind=*
+
+unset x y
+
+x=$*
+y=${!ind}
+
+recho "$x"
+recho "$y"
+
+unset x y
+
+recho ${x-$*}
+recho ${y-${!ind}} # this isn't right yet
+
+unset x y
+
+recho ${x=$*}
+recho ${y=${!ind}}
+
+set -- ' X '
+IFS=$' \t\n'
+
+x=$*
+y=${!ind};
+
+recho "$x"
+recho "$y"
+
+IFS=''
+x=$*
+y=${!ind}
+
+recho "$x"
+recho "$y"
+
+IFS=:
+set -- a b
+ind=*
+
+unset x y
+
+recho ${x-$*}
+recho ${y-${!ind}} # this isn't right yet
+
+unset x y
+
+recho ${x=$*}
+recho ${y=${!ind}}
+
+set -- ' X '
+IFS=$' \t\n'
+
+unset x y
+
+x=$*
+y=${!ind};
+
+recho "$x"
+recho "$y"
+
+IFS=''
+x=$*
+y=${!ind}
+
+recho "$x"
+recho "$y"
+
+IFS=''
+set -- $'\177'
+
+unset -v var
+
+recho "${*:1}"
+var=${*:1}
+recho "$var"
+
+unset var
+recho ${var=${*:1}}
+recho "$var"
+
+declare -a a=($'\177')
+
+unset var
+var=${a[*]:0}
+recho "$var"
+
+unset var
+recho ${var=${a[*]:0}}
+unset var
+
+set -- $'\177'
+ind='*'
+
+recho $*
+var=${!ind}
+recho "$var"
+
+unset var
+recho ${var=${!ind}}
+recho "$var"
+
+declare -A A=([0]=$'\177')
+
+unset var
+var=${A[*]:0}
+recho "$var"
+
+# this isn't really right yet
+unset var
+recho ${var=${A[*]:0}}
+recho "$var"
diff --git a/tests/dollar-at1.sub b/tests/dollar-at1.sub
index 6d407863..c5079d64 100644
--- a/tests/dollar-at1.sub
+++ b/tests/dollar-at1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
echo_argc()
{
echo $#
diff --git a/tests/dollar-at2.sub b/tests/dollar-at2.sub
index c079a295..16defbdc 100644
--- a/tests/dollar-at2.sub
+++ b/tests/dollar-at2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
t1()
{
xxx="echo $@"
diff --git a/tests/dollar-at5.sub b/tests/dollar-at5.sub
index 75e2249f..9b26c392 100644
--- a/tests/dollar-at5.sub
+++ b/tests/dollar-at5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
args() { printf '<%s> ' "$@"; echo; }
set -- 1 2 3 4 5
diff --git a/tests/dollar-at6.sub b/tests/dollar-at6.sub
index 039e11f8..791fd899 100644
--- a/tests/dollar-at6.sub
+++ b/tests/dollar-at6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- '';
recho "${@}" x
diff --git a/tests/dollar-at7.sub b/tests/dollar-at7.sub
index 311a6fef..cde11648 100644
--- a/tests/dollar-at7.sub
+++ b/tests/dollar-at7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- ''
recho 1 ''"$@"
diff --git a/tests/dollar-star1.sub b/tests/dollar-star1.sub
index 63a9ef86..3e5ec36d 100644
--- a/tests/dollar-star1.sub
+++ b/tests/dollar-star1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- a b c
x=(a b c); IFS='|'
diff --git a/tests/dollar-star10.sub b/tests/dollar-star10.sub
new file mode 100644
index 00000000..fce9ec1f
--- /dev/null
+++ b/tests/dollar-star10.sub
@@ -0,0 +1,92 @@
+# 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/>.
+#
+oIFS=$IFS
+
+set -- ''
+
+unset v
+recho ${v= ''}
+recho $v
+unset v
+recho ${v=''}
+recho $v
+unset v
+recho ${v= $*}
+recho $v
+unset v
+recho ${v=$*}
+recho $v
+unset v
+recho ${v='' }
+recho $v
+unset v
+recho ${v= '' }
+recho $v
+unset v
+recho ${v=$* }
+recho $v
+unset v
+recho ${v= $* }
+recho $v
+
+unset IFS
+
+unset v
+recho ${v= ''}
+recho $v
+unset v
+recho ${v=''}
+recho $v
+unset v
+recho ${v= $*}
+recho $v
+unset v
+recho ${v=$*}
+recho $v
+unset v
+recho ${v='' }
+recho $v
+unset v
+recho ${v= '' }
+recho $v
+unset v
+recho ${v=$* }
+recho $v
+unset v
+recho ${v= $* }
+recho $v
+
+unset -v v
+IFS=$oIFS
+
+# This shouldn't output anything
+set -- '' ''
+
+unset -v v
+recho ${v=$*}
+unset -v v
+recho ${v= $*}
+unset -v v
+recho ${v=$* }
+unset -v v
+recho ${v= $* }
+
+unset -v v IFS
+recho ${v=$*}
+unset -v v
+recho ${v= $*}
+unset -v v
+recho ${v= $* }
+unset -v v
+recho ${v= $*}
diff --git a/tests/dollar-star2.sub b/tests/dollar-star2.sub
index 844a2972..78e00a0c 100644
--- a/tests/dollar-star2.sub
+++ b/tests/dollar-star2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set A B
IFS=
diff --git a/tests/dollar-star3.sub b/tests/dollar-star3.sub
index 8cf4bb22..a6ef09fe 100644
--- a/tests/dollar-star3.sub
+++ b/tests/dollar-star3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
IFS=/
#file=/mnt/cdrom/RedHat/RPMS
#recho "${file[*]:0:3}"
diff --git a/tests/dollar-star5.sub b/tests/dollar-star5.sub
index 8448bf3c..abd8bcc2 100644
--- a/tests/dollar-star5.sub
+++ b/tests/dollar-star5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- a b
IFS=
diff --git a/tests/dollar-star6.sub b/tests/dollar-star6.sub
index dbd59ecf..095ec04f 100644
--- a/tests/dollar-star6.sub
+++ b/tests/dollar-star6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
recho "A${*:-w}R"
recho "A${*-w}R"
recho "A${*}R"
diff --git a/tests/dollar-star7.sub b/tests/dollar-star7.sub
index 72d6c24f..db352bfc 100644
--- a/tests/dollar-star7.sub
+++ b/tests/dollar-star7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# if IFS side effects in ${IFS=} assignments take place, how do you cope with
# later changes to IFS in the same set of expansions? You've already
# committed to using the first character of the (old) IFS to expand $* in
diff --git a/tests/dollar-star8.sub b/tests/dollar-star8.sub
index 72ba1080..e6265646 100644
--- a/tests/dollar-star8.sub
+++ b/tests/dollar-star8.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
IFS=
set "abc" "def ghi" "jkl"
diff --git a/tests/dollar-star9.sub b/tests/dollar-star9.sub
index 26d0ed21..d46de46a 100644
--- a/tests/dollar-star9.sub
+++ b/tests/dollar-star9.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- 1 2
IFS=
diff --git a/tests/dollar.right b/tests/dollar.right
index d72361f9..09910d7e 100644
--- a/tests/dollar.right
+++ b/tests/dollar.right
@@ -226,6 +226,7 @@ null fields in rhs
null string with unquoted $@
argv[1] = <>
null string with quoted $@
+argv[1] = <>
assignment
argv[1] = <>
variable
@@ -301,6 +302,103 @@ 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
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = <>
+argv[1] = < X >
+argv[1] = <>
+argv[1] = < X >
+argv[1] = <>
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X>
+argv[2] = <Y >
+argv[1] = < X>
+argv[2] = <Y >
+argv[1] = < X>
+argv[2] = <Y >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < XY >
+argv[1] = < XY >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < X Y >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = <ba>
+argv[1] = <ba>
+argv[1] = <ba>
+argv[1] = <b>
+argv[2] = <a>
+argv[1] = <a:b>
+argv[1] = <a:b>
+argv[1] = <a>
+argv[2] = <b>
+argv[1] = <a>
+argv[2] = <b>
+argv[1] = <a>
+argv[2] = <b>
+argv[1] = <a>
+argv[2] = <b>
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = <a>
+argv[2] = <b>
+argv[1] = <a>
+argv[2] = <b>
+argv[1] = <a>
+argv[2] = <b>
+argv[1] = <a>
+argv[2] = <b>
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = < X >
+argv[1] = <^?>
+argv[1] = <>
+argv[1] = <>
+argv[1] = <>
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <>
+argv[1] = <>
xa|xb|xc
xa|xb|xc
a|b|c
diff --git a/tests/dstack.right b/tests/dstack.right
index 8f27d28b..8f9d38c0 100644
--- a/tests/dstack.right
+++ b/tests/dstack.right
@@ -1,13 +1,13 @@
-./dstack.tests: line 6: pushd: /tmp/xxx-notthere: No such file or directory
-./dstack.tests: line 9: pushd: no other directory
-./dstack.tests: line 10: popd: directory stack empty
-./dstack.tests: line 13: pushd: -m: invalid number
+./dstack.tests: line 19: pushd: /tmp/xxx-notthere: No such file or directory
+./dstack.tests: line 22: pushd: no other directory
+./dstack.tests: line 23: popd: directory stack empty
+./dstack.tests: line 26: pushd: -m: invalid number
pushd: usage: pushd [-n] [+N | -N | dir]
-./dstack.tests: line 14: popd: -m: invalid number
+./dstack.tests: line 27: popd: -m: invalid number
popd: usage: popd [-n] [+N | -N]
-./dstack.tests: line 15: dirs: -m: invalid number
+./dstack.tests: line 28: dirs: -m: invalid number
dirs: usage: dirs [-clpv] [+N] [-N]
-./dstack.tests: line 16: dirs: 7: invalid option
+./dstack.tests: line 29: dirs: 7: invalid option
dirs: usage: dirs [-clpv] [+N] [-N]
/
ok
@@ -31,12 +31,12 @@ ok
/tmp
/usr
/usr
-./dstack.tests: line 58: dirs: 9: directory stack index out of range
-./dstack.tests: line 58: dirs: 9: directory stack index out of range
-./dstack.tests: line 59: pushd: +9: directory stack index out of range
-./dstack.tests: line 59: pushd: -9: directory stack index out of range
-./dstack.tests: line 60: popd: +9: directory stack index out of range
-./dstack.tests: line 60: popd: -9: directory stack index out of range
+./dstack.tests: line 71: dirs: 9: directory stack index out of range
+./dstack.tests: line 71: dirs: 9: directory stack index out of range
+./dstack.tests: line 72: pushd: +9: directory stack index out of range
+./dstack.tests: line 72: pushd: -9: directory stack index out of range
+./dstack.tests: line 73: popd: +9: directory stack index out of range
+./dstack.tests: line 73: popd: -9: directory stack index out of range
/tmp /etc /
/tmp /etc /
/tmp /etc /
diff --git a/tests/dstack.tests b/tests/dstack.tests
index 49b97d3f..116e935f 100644
--- a/tests/dstack.tests
+++ b/tests/dstack.tests
@@ -1,8 +1,21 @@
+# 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/>.
+#
export LC_ALL=C
export LANG=C
dirs -c
-# error -- nonexistant directory
+# error -- non-existent directory
pushd /tmp/xxx-notthere
# errors -- empty stack
diff --git a/tests/dstack2.tests b/tests/dstack2.tests
index 3aa105b3..08733198 100644
--- a/tests/dstack2.tests
+++ b/tests/dstack2.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
wdir=$PWD
cd /
diff --git a/tests/dynvar.tests b/tests/dynvar.tests
index a01f5ed2..5aefab64 100644
--- a/tests/dynvar.tests
+++ b/tests/dynvar.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# specvar -- test some of the dynamic variables
# BASHPID
@@ -37,7 +50,7 @@ unset before after
# EPOCHSECONDS
# not exact, but should work
-
+# could also use python -c 'import time; ts = int(time.time()); print(ts)'
now1=$(perl -e 'print time')
now2=$EPOCHSECONDS
diff --git a/tests/errors.right b/tests/errors.right
index 83338ae0..be0c8959 100644
--- a/tests/errors.right
+++ b/tests/errors.right
@@ -1,109 +1,108 @@
-./errors.tests: line 17: alias: -x: invalid option
+./errors.tests: line 30: alias: -x: invalid option
alias: usage: alias [-p] [name[=value] ... ]
-./errors.tests: line 18: unalias: -x: invalid option
+./errors.tests: line 31: unalias: -x: invalid option
unalias: usage: unalias [-a] name [name ...]
-./errors.tests: line 19: alias: hoowah: not found
-./errors.tests: line 20: unalias: hoowah: not found
-./errors.tests: line 23: `1': not a valid identifier
+./errors.tests: line 32: alias: hoowah: not found
+./errors.tests: line 33: unalias: hoowah: not found
+./errors.tests: line 36: `1': not a valid identifier
declare -fr func
-./errors.tests: line 36: func: readonly function
-./errors.tests: line 39: unset: -x: invalid option
+./errors.tests: line 49: func: readonly function
+./errors.tests: line 52: unset: -x: invalid option
unset: usage: unset [-f] [-v] [-n] [name ...]
-./errors.tests: line 42: unset: func: cannot unset: readonly function
-./errors.tests: line 45: declare: func: readonly function
-./errors.tests: line 49: unset: XPATH: cannot unset: readonly variable
-./errors.tests: line 52: unset: `/bin/sh': not a valid identifier
-./errors.tests: line 55: unset: cannot simultaneously unset a function and a variable
-./errors.tests: line 58: declare: -z: invalid option
-declare: usage: declare [-aAfFgilnrtux] [-p] [name[=value] ...]
-./errors.tests: line 60: declare: `-z': not a valid identifier
-./errors.tests: line 61: declare: `/bin/sh': not a valid identifier
-./errors.tests: line 65: declare: cannot use `-f' to make functions
-./errors.tests: line 68: exec: -i: invalid option
-exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
-./errors.tests: line 72: export: XPATH: not a function
-./errors.tests: line 75: break: only meaningful in a `for', `while', or `until' loop
-./errors.tests: line 76: continue: only meaningful in a `for', `while', or `until' loop
-./errors.tests: line 79: shift: label: numeric argument required
-./errors.tests: line 84: shift: too many arguments
-./errors.tests: line 90: let: expression expected
-./errors.tests: line 93: local: can only be used in a function
-./errors.tests: line 96: logout: not login shell: use `exit'
-./errors.tests: line 99: hash: notthere: not found
-./errors.tests: line 102: hash: -v: invalid option
+./errors.tests: line 55: unset: func: cannot unset: readonly function
+./errors.tests: line 58: declare: func: readonly function
+./errors.tests: line 62: unset: XPATH: cannot unset: readonly variable
+./errors.tests: line 68: unset: cannot simultaneously unset a function and a variable
+./errors.tests: line 71: declare: -z: invalid option
+declare: usage: declare [-aAfFgiIlnrtux] [-p] [name[=value] ...]
+./errors.tests: line 73: declare: `-z': not a valid identifier
+./errors.tests: line 74: declare: `/bin/sh': not a valid identifier
+./errors.tests: line 78: declare: cannot use `-f' to make functions
+./errors.tests: line 81: exec: -i: invalid option
+exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
+./errors.tests: line 85: export: XPATH: not a function
+./errors.tests: line 88: break: only meaningful in a `for', `while', or `until' loop
+./errors.tests: line 89: continue: only meaningful in a `for', `while', or `until' loop
+./errors.tests: line 92: shift: label: numeric argument required
+./errors.tests: line 97: shift: too many arguments
+./errors.tests: line 103: let: expression expected
+./errors.tests: line 106: local: can only be used in a function
+./errors.tests: line 109: logout: not login shell: use `exit'
+./errors.tests: line 112: hash: notthere: not found
+./errors.tests: line 115: hash: -v: invalid option
hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
-./errors.tests: line 106: hash: hashing disabled
-./errors.tests: line 109: export: `AA[4]': not a valid identifier
-./errors.tests: line 110: readonly: `AA[4]': not a valid identifier
-./errors.tests: line 113: unset: [-2]: bad array subscript
-./errors.tests: line 117: AA: readonly variable
-./errors.tests: line 121: AA: readonly variable
-./errors.tests: line 129: shift: 5: shift count out of range
-./errors.tests: line 130: shift: -2: shift count out of range
-./errors.tests: line 133: shopt: no_such_option: invalid shell option name
-./errors.tests: line 134: shopt: no_such_option: invalid shell option name
-./errors.tests: line 137: umask: 09: octal number out of range
-./errors.tests: line 138: umask: `:': invalid symbolic mode character
-./errors.tests: line 139: umask: `:': invalid symbolic mode operator
-./errors.tests: line 142: umask: -i: invalid option
+./errors.tests: line 119: hash: hashing disabled
+./errors.tests: line 122: export: `AA[4]': not a valid identifier
+./errors.tests: line 123: readonly: `AA[4]': not a valid identifier
+./errors.tests: line 126: unset: [-2]: bad array subscript
+./errors.tests: line 130: AA: readonly variable
+./errors.tests: line 134: AA: readonly variable
+./errors.tests: line 142: shift: 5: shift count out of range
+./errors.tests: line 143: shift: -2: shift count out of range
+./errors.tests: line 146: shopt: no_such_option: invalid shell option name
+./errors.tests: line 147: shopt: no_such_option: invalid shell option name
+./errors.tests: line 150: umask: 09: octal number out of range
+./errors.tests: line 151: umask: `:': invalid symbolic mode character
+./errors.tests: line 152: umask: `:': invalid symbolic mode operator
+./errors.tests: line 155: umask: -i: invalid option
umask: usage: umask [-p] [-S] [mode]
-./errors.tests: line 146: umask: `u': invalid symbolic mode character
-./errors.tests: line 155: VAR: readonly variable
-./errors.tests: line 158: declare: VAR: readonly variable
-./errors.tests: line 159: declare: VAR: readonly variable
-./errors.tests: line 161: declare: unset: not found
-./errors.tests: line 164: VAR: readonly variable
-./errors.tests: command substitution: line 168: syntax error near unexpected token `)'
-./errors.tests: command substitution: line 168: ` for z in 1 2 3; do )'
-./errors.tests: command substitution: line 169: syntax error near unexpected token `done'
-./errors.tests: command substitution: line 169: ` for z in 1 2 3; done )'
-./errors.tests: line 171: cd: HOME not set
-./errors.tests: line 172: cd: /tmp/xyz.bash: No such file or directory
-./errors.tests: line 174: cd: OLDPWD not set
-./errors.tests: line 175: cd: /bin/sh: Not a directory
-./errors.tests: line 177: cd: /tmp/cd-notthere: No such file or directory
-./errors.tests: line 180: .: filename argument required
+./errors.tests: line 159: umask: `u': invalid symbolic mode character
+./errors.tests: line 168: VAR: readonly variable
+./errors.tests: line 171: declare: VAR: readonly variable
+./errors.tests: line 172: declare: VAR: readonly variable
+./errors.tests: line 174: declare: unset: not found
+./errors.tests: line 177: VAR: readonly variable
+./errors.tests: command substitution: line 181: syntax error near unexpected token `)'
+./errors.tests: command substitution: line 181: ` for z in 1 2 3; do )'
+./errors.tests: command substitution: line 182: syntax error near unexpected token `done'
+./errors.tests: command substitution: line 182: ` for z in 1 2 3; done )'
+./errors.tests: line 184: cd: HOME not set
+./errors.tests: line 185: cd: /tmp/xyz.bash: No such file or directory
+./errors.tests: line 187: cd: OLDPWD not set
+./errors.tests: line 188: cd: /bin/sh: Not a directory
+./errors.tests: line 190: cd: /tmp/cd-notthere: No such file or directory
+./errors.tests: line 193: .: filename argument required
.: usage: . filename [arguments]
-./errors.tests: line 181: source: filename argument required
+./errors.tests: line 194: source: filename argument required
source: usage: source filename [arguments]
-./errors.tests: line 184: .: -i: invalid option
+./errors.tests: line 197: .: -i: invalid option
.: usage: . filename [arguments]
-./errors.tests: line 187: set: -q: invalid option
+./errors.tests: line 200: set: -q: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
-./errors.tests: line 190: enable: sh: not a shell builtin
-./errors.tests: line 190: enable: bash: not a shell builtin
-./errors.tests: line 193: shopt: cannot set and unset shell options simultaneously
-./errors.tests: line 196: read: var: invalid timeout specification
-./errors.tests: line 199: read: `/bin/sh': not a valid identifier
-./errors.tests: line 202: VAR: readonly variable
-./errors.tests: line 205: readonly: -x: invalid option
+./errors.tests: line 203: enable: sh: not a shell builtin
+./errors.tests: line 203: enable: bash: not a shell builtin
+./errors.tests: line 206: shopt: cannot set and unset shell options simultaneously
+./errors.tests: line 209: read: var: invalid timeout specification
+./errors.tests: line 212: read: `/bin/sh': not a valid identifier
+./errors.tests: line 215: VAR: readonly variable
+./errors.tests: line 218: readonly: -x: invalid option
readonly: usage: readonly [-aAf] [name[=value] ...] or readonly -p
-./errors.tests: line 208: eval: -i: invalid option
+./errors.tests: line 221: eval: -i: invalid option
eval: usage: eval [arg ...]
-./errors.tests: line 209: command: -i: invalid option
+./errors.tests: line 222: command: -i: invalid option
command: usage: command [-pVv] command [arg ...]
-./errors.tests: line 212: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
-./errors.tests: line 213: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
-./errors.tests: line 216: trap: NOSIG: invalid signal specification
-./errors.tests: line 219: trap: -s: invalid option
+./errors.tests: line 225: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
+./errors.tests: line 226: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
+./errors.tests: line 229: trap: NOSIG: invalid signal specification
+./errors.tests: line 232: trap: -s: invalid option
trap: usage: trap [-lp] [[arg] signal_spec ...]
-./errors.tests: line 225: return: can only `return' from a function or sourced script
-./errors.tests: line 229: break: 0: loop count out of range
-./errors.tests: line 233: continue: 0: loop count out of range
-./errors.tests: line 238: builtin: bash: not a shell builtin
-./errors.tests: line 242: bg: no job control
-./errors.tests: line 243: fg: no job control
-./errors.tests: line 246: kill: -s: option requires an argument
-./errors.tests: line 248: kill: S: invalid signal specification
-./errors.tests: line 250: kill: `': not a pid or valid job spec
+./errors.tests: line 238: return: can only `return' from a function or sourced script
+./errors.tests: line 242: break: 0: loop count out of range
+./errors.tests: line 246: continue: 0: loop count out of range
+./errors.tests: line 251: builtin: bash: not a shell builtin
+./errors.tests: line 255: bg: no job control
+./errors.tests: line 256: fg: no job control
+./errors.tests: line 259: kill: -s: option requires an argument
+./errors.tests: line 261: kill: S: invalid signal specification
+./errors.tests: line 263: 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 255: set: trackall: invalid option name
-./errors.tests: line 259: xx: readonly variable
+./errors.tests: line 268: set: trackall: invalid option name
+./errors.tests: line 272: xx: readonly variable
1
-./errors1.sub: line 1: .: -i: invalid option
+./errors1.sub: line 14: .: -i: invalid option
.: usage: . filename [arguments]
-./errors1.sub: line 9: shift: -4: shift count out of range
-./errors1.sub: line 14: break: -1: loop count out of range
+./errors1.sub: line 22: shift: -4: shift count out of range
+./errors1.sub: line 27: break: -1: loop count out of range
after f
./errors2.sub: line 3: ${$NO_SUCH_VAR}: bad substitution
1
@@ -112,12 +111,12 @@ TEST
./errors3.sub: line 7: no_such_file: No such file or directory
1
2
-./errors4.sub: line 7: var: readonly variable
+./errors4.sub: line 20: var: readonly variable
after readonly assignment
-./errors4.sub: line 13: break: x: numeric argument required
+./errors4.sub: line 26: break: x: numeric argument required
1
2
-./errors4.sub: line 7: var: readonly variable
+./errors4.sub: line 20: var: readonly variable
./errors5.sub: line 6: array: unbound variable
./errors5.sub: line 7: array: unbound variable
./errors5.sub: line 8: array[7]: unbound variable
@@ -130,59 +129,59 @@ after 3: 1
array after 1: 0
array after 2: 0
-./errors6.sub: uvar: parameter not set
-./errors6.sub: uvar: parameter null or not set
+./errors6.sub: line 1: uvar: parameter not set
+./errors6.sub: line 1: uvar: parameter null or not set
-./errors6.sub: uvar: parameter null or not set
-./errors6.sub: line 25: ${-3:-${-3}}: bad substitution
-./errors6.sub: line 26: ${-3}: bad substitution
-./errors6.sub: line 27: -3: invalid variable name
+./errors6.sub: line 1: uvar: parameter null or not set
+./errors6.sub: line 38: ${-3:-${-3}}: bad substitution
+./errors6.sub: line 39: ${-3}: bad substitution
+./errors6.sub: line 40: -3: invalid variable name
after indir: 1
-./errors6.sub: line 30: -3: invalid variable name
+./errors6.sub: line 43: -3: invalid variable name
unset
-./errors6.sub: line 37: var: invalid indirect expansion
-./errors6.sub: line 38: var: invalid indirect expansion
-./errors6.sub: line 41: invalid-ident: invalid variable name
-./errors6.sub: line 42: invalid-ident: invalid variable name
-./errors6.sub: line 43: invalid-ident: invalid variable name
+./errors6.sub: line 50: var: invalid indirect expansion
+./errors6.sub: line 51: var: invalid indirect expansion
+./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
4
array after 1: 0
array after 2: 0
-./errors6.sub: uvar: parameter not set
-./errors6.sub: uvar: parameter null or not set
+./errors6.sub: line 1: uvar: parameter not set
+./errors6.sub: line 1: uvar: parameter null or not set
-./errors6.sub: uvar: parameter null or not set
-./errors6.sub: line 25: ${-3:-${-3}}: bad substitution
-./errors6.sub: line 26: ${-3}: bad substitution
-./errors6.sub: line 27: -3: invalid variable name
+./errors6.sub: line 1: uvar: parameter null or not set
+./errors6.sub: line 38: ${-3:-${-3}}: bad substitution
+./errors6.sub: line 39: ${-3}: bad substitution
+./errors6.sub: line 40: -3: invalid variable name
after indir: 1
-./errors6.sub: line 30: -3: invalid variable name
+./errors6.sub: line 43: -3: invalid variable name
unset
-./errors6.sub: line 37: var: invalid indirect expansion
-./errors6.sub: line 38: var: invalid indirect expansion
-./errors6.sub: line 41: invalid-ident: invalid variable name
-./errors6.sub: line 42: invalid-ident: invalid variable name
-./errors6.sub: line 43: invalid-ident: invalid variable name
-./errors7.sub: line 8: x: readonly variable
-./errors7.sub: line 8: notthere: command not found
+./errors6.sub: line 50: var: invalid indirect expansion
+./errors6.sub: line 51: var: invalid indirect expansion
+./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: line 21: x: readonly variable
+./errors7.sub: line 21: notthere: command not found
after no such command: 127
-./errors7.sub: line 10: x: readonly variable
+./errors7.sub: line 23: x: readonly variable
echo builtin
after non-special builtin: 0
-./errors7.sub: line 12: x: readonly variable
+./errors7.sub: line 25: x: readonly variable
after special builtin: 0
-./errors7.sub: line 14: x: readonly variable
-./errors7.sub: line 8: x: readonly variable
-./errors7.sub: line 8: notthere: command not found
+./errors7.sub: line 27: x: readonly variable
+./errors7.sub: line 21: x: readonly variable
+./errors7.sub: line 21: notthere: command not found
after no such command: 127
-./errors7.sub: line 10: x: readonly variable
+./errors7.sub: line 23: x: readonly variable
echo builtin
after non-special builtin: 0
-./errors7.sub: line 12: x: readonly variable
-./errors7.sub: line 14: x: readonly variable
+./errors7.sub: line 25: x: readonly variable
+./errors7.sub: line 27: x: readonly variable
./errors8.sub: eval: line 7: syntax error: unexpected end of file
ok 1
./errors8.sub: line 8: v: readonly variable
@@ -195,4 +194,7 @@ ok 4
ok 5
./errors8.sub: line 14: set: notanoption: invalid option name
ok 6
-./errors.tests: line 283: `!!': not a valid identifier
+bash: line 1: return: can only `return' from a function or sourced script
+after return
+bash: line 1: return: can only `return' from a function or sourced script
+./errors.tests: line 299: `!!': not a valid identifier
diff --git a/tests/errors.tests b/tests/errors.tests
index e1554cd1..531b625b 100644
--- a/tests/errors.tests
+++ b/tests/errors.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# These should all be safe
LC_ALL=C
LC_CTYPE=C
@@ -95,7 +108,7 @@ local
# logout of a non-login shell is an error
logout
-# try to hash a non-existant command
+# try to hash a non-existent command
hash notthere
# bad option to hash, although it may mean `verbose' at some future point
@@ -275,6 +288,9 @@ ${THIS_SH} -o posix ./errors7.sub
${THIS_SH} ./errors8.sub
+${THIS_SH} -c 'return ; echo after return' bash
+${THIS_SH} -o posix -c 'return ; echo after return' bash
+
# this must be last!
# in posix mode, a function name must be a valid identifier
# this can't go in posix2.tests, since it causes the shell to exit
diff --git a/tests/errors1.sub b/tests/errors1.sub
index 8e7440b5..52a9e342 100644
--- a/tests/errors1.sub
+++ b/tests/errors1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
. -i /dev/tty
f()
diff --git a/tests/errors4.sub b/tests/errors4.sub
index 8451b961..6b405024 100644
--- a/tests/errors4.sub
+++ b/tests/errors4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test effect of assigning to readonly vars on loops and non-interactive shells
# fatal error when in posix mode
var=foo
diff --git a/tests/errors6.sub b/tests/errors6.sub
index b80580e7..cac2c55b 100644
--- a/tests/errors6.sub
+++ b/tests/errors6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# problems with non-fatal expansion errors through bash-4.3
: ${THIS_SH:=./bash}
diff --git a/tests/errors7.sub b/tests/errors7.sub
index 067867a1..add8782a 100644
--- a/tests/errors7.sub
+++ b/tests/errors7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${THIS_SH:=./bash}
readonly x=4
diff --git a/tests/exec.right b/tests/exec.right
index 6075cc86..0a249dda 100644
--- a/tests/exec.right
+++ b/tests/exec.right
@@ -105,3 +105,31 @@ x2b
x3
x3a
x3b
+WORKS
+done
+WORKS
+WORKS
+a
+b
+c
+d
+a
+b
+c
+d
+e
+A
+B
+c
+d
+c
+d
+e
+x
+y
+z
+WORKS
+w
+x
+y
+z
diff --git a/tests/exec10.sub b/tests/exec10.sub
index af3ab0d9..db6a6710 100644
--- a/tests/exec10.sub
+++ b/tests/exec10.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# post bash-4.3 changes to how command -p works (avoid modifying $PATH)
: ${TMPDIR=/tmp}
diff --git a/tests/exec12.sub b/tests/exec12.sub
index 79bcfc77..0d7c8b89 100644
--- a/tests/exec12.sub
+++ b/tests/exec12.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${TMPDIR:=/var/tmp}
TMPFILE=$TMPDIR/exitcode
trap 'rm -f $TMPFILE' 0
diff --git a/tests/exec13.sub b/tests/exec13.sub
index 0f84daaa..76e13246 100644
--- a/tests/exec13.sub
+++ b/tests/exec13.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
echo x1 | ( cat & wait )
echo x1a | ( :& cat & wait )
diff --git a/tests/exec14.sub b/tests/exec14.sub
new file mode 100644
index 00000000..3402fb95
--- /dev/null
+++ b/tests/exec14.sub
@@ -0,0 +1,47 @@
+# 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 that optimizing command lists doesn't inappropriately short-cut commands
+
+# also includes optimizing last command in a list separated by `;'
+
+if [ -x /bin/echo ] ; then
+ binecho=/bin/echo
+elif [ -x /usr/bin/echo ]; then
+ binecho=/usr/bin/echo
+else
+ enable -n echo
+ binecho=echo
+fi
+
+export binecho
+
+: ${THIS_SH:=./bash} ${TMPDIR:=/var/tmp}
+
+${THIS_SH} -c 'trap "echo WORKS && rm $TMPDIR/x$$" EXIT && touch $TMPDIR/x$$'
+${THIS_SH} -c 'trap "echo WORKS && rm $TMPDIR/x$$" EXIT && touch $TMPDIR/x$$ ; $binecho done'
+
+( trap "echo WORKS && rm $TMPDIR/x$$" EXIT && touch $TMPDIR/x$$ )
+
+${THIS_SH} -c 'echo a && { $binecho b && $binecho c ; } && echo d'
+${THIS_SH} -c 'echo a && { $binecho b && $binecho c ; } && echo d ; $binecho e'
+
+${THIS_SH} -c 'echo A && $binecho B'
+${THIS_SH} -c '$binecho c && echo d'
+
+$THIS_SH -c '$binecho c && $binecho d && echo e'
+
+$THIS_SH -c 'trap "echo WORKS" EXIT ; $binecho x ; $binecho y ; $binecho z'
+
+${THIS_SH} -c 'echo w ; { echo x ; $binecho y; }; $binecho z'
diff --git a/tests/exec6.sub b/tests/exec6.sub
index 50d0e701..dd53e74b 100644
--- a/tests/exec6.sub
+++ b/tests/exec6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# builtins with exit status inverted
( true )
diff --git a/tests/exec7.sub b/tests/exec7.sub
index 0267505c..0c8c7cab 100644
--- a/tests/exec7.sub
+++ b/tests/exec7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# make sure that bash really checks the right things when deciding what
# constitutes an executable file
diff --git a/tests/exec9.sub b/tests/exec9.sub
index b8d20b44..a47dfd00 100644
--- a/tests/exec9.sub
+++ b/tests/exec9.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# make sure commands before the last one in the pipeline can't change $?
false
false | echo $?
diff --git a/tests/execscript b/tests/execscript
index c1819de7..28096769 100644
--- a/tests/execscript
+++ b/tests/execscript
@@ -157,3 +157,4 @@ $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
diff --git a/tests/exp.right b/tests/exp.right
index a2dc86f9..4e88ca9b 100644
--- a/tests/exp.right
+++ b/tests/exp.right
@@ -150,6 +150,9 @@ argv[4] = <d>
argv[5] = <e>
a?b?c
a b c
+argv[1] = <a>
+argv[2] = <b>
+argv[3] = <>
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <^?>
@@ -232,7 +235,7 @@ declare -- var="x\001y\177z"$
argv[1] = <$'x\001y\177z'>
argv[1] = <x^Ay^?z>
var=$'x\001y\177z'
-./exp8.sub: line 16: xyz: syntax error: invalid arithmetic operator (error token is "z")
+./exp8.sub: line 29: xyz: syntax error: invalid arithmetic operator (error token is "z")
declare -a array=()
declare -a array=([0]=$'x\001y\177z')
argv[1] = <x^Ay^?z>
diff --git a/tests/exp.tests b/tests/exp.tests
index 6e364f9c..3e69db4f 100644
--- a/tests/exp.tests
+++ b/tests/exp.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
#
# A suite of tests for bash word expansions
#
@@ -391,6 +404,8 @@ echo ${a//\\?/ }
echo ${a//\?/ }
+${THIS_SH} -c 'var=a:b: ; IFS=" :" ; recho $var""' bash
+
${THIS_SH} ./exp1.sub
${THIS_SH} ./exp2.sub
diff --git a/tests/exp1.sub b/tests/exp1.sub
index 3e40f2a9..3dbe3d90 100644
--- a/tests/exp1.sub
+++ b/tests/exp1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# Test the substitution quoting characters (CTLESC and CTLNUL) in different
# combinations
diff --git a/tests/exp10.sub b/tests/exp10.sub
index 6592bab9..42bdaf87 100644
--- a/tests/exp10.sub
+++ b/tests/exp10.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- ' A ' ' B '
IFS=
diff --git a/tests/exp11.sub b/tests/exp11.sub
index cae7b19c..b3e02e08 100644
--- a/tests/exp11.sub
+++ b/tests/exp11.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- '1 2'
unset var
diff --git a/tests/exp12.sub b/tests/exp12.sub
index 0aaa2f44..8c5005dc 100644
--- a/tests/exp12.sub
+++ b/tests/exp12.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# force single-byte versions of these functions
export LANG=C
diff --git a/tests/exp5.sub b/tests/exp5.sub
index 52dd4a15..5cf8ed71 100644
--- a/tests/exp5.sub
+++ b/tests/exp5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# expansions involving patterns
var='[hello'
echo "${var//[/}"
diff --git a/tests/exp6.sub b/tests/exp6.sub
index a1c9fe63..582617c2 100644
--- a/tests/exp6.sub
+++ b/tests/exp6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
recho """"a
recho a""""
diff --git a/tests/exp7.sub b/tests/exp7.sub
index f3f3b6bd..a3993b50 100644
--- a/tests/exp7.sub
+++ b/tests/exp7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
IFS=$'\001'
c=$'\001'
c2=$'\003'
diff --git a/tests/exp8.sub b/tests/exp8.sub
index ff44febc..4c2870ca 100644
--- a/tests/exp8.sub
+++ b/tests/exp8.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
var=$'x\001y\177z'
recho "$var"
diff --git a/tests/exp9.sub b/tests/exp9.sub
index a0399c7a..7e4a3b63 100644
--- a/tests/exp9.sub
+++ b/tests/exp9.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# expansion test cases from Posix interp 888
set "abc" "def ghi" "jkl"
diff --git a/tests/exportfunc.right b/tests/exportfunc.right
index 2ee35a7a..ff7fc8d9 100644
--- a/tests/exportfunc.right
+++ b/tests/exportfunc.right
@@ -1,14 +1,14 @@
exportfunc ok 1
exportfunc ok 2
-./exportfunc.tests: line 24: cve7169-bad: No such file or directory
-./exportfunc.tests: eval: line 31: syntax error: unexpected end of file
-./exportfunc.tests: line 30: cve7169-bad2: No such file or directory
-./exportfunc1.sub: line 1: maximum here-document count exceeded
-./exportfunc.tests: line 51: HELLO_WORLD: No such file or directory
+./exportfunc.tests: line 37: cve7169-bad: No such file or directory
+./exportfunc.tests: eval: line 44: syntax error: unexpected end of file
+./exportfunc.tests: line 43: cve7169-bad2: No such file or directory
+./exportfunc1.sub: line 14: maximum here-document count exceeded
+./exportfunc.tests: line 64: HELLO_WORLD: No such file or directory
eval ok
-./exportfunc3.sub: line 10: export: foo=bar: cannot export
+./exportfunc3.sub: line 23: export: foo=bar: cannot export
status: 1
equals-1
bad echo
-./exportfunc3.sub: line 23: export: /bin/echo: cannot export
+./exportfunc3.sub: line 36: export: /bin/echo: cannot export
bar
diff --git a/tests/exportfunc.tests b/tests/exportfunc.tests
index f5ef54f0..b2742d2c 100644
--- a/tests/exportfunc.tests
+++ b/tests/exportfunc.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# normal operation
foo()
{
diff --git a/tests/exportfunc1.sub b/tests/exportfunc1.sub
index d9c9fa1c..53b4c1fb 100644
--- a/tests/exportfunc1.sub
+++ b/tests/exportfunc1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
cat <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF
EOF
EOF
diff --git a/tests/exportfunc2.sub b/tests/exportfunc2.sub
index 886b71bb..cf5df571 100644
--- a/tests/exportfunc2.sub
+++ b/tests/exportfunc2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
for x1 in ; do :
for x2 in ; do :
for x3 in ; do :
diff --git a/tests/exportfunc3.sub b/tests/exportfunc3.sub
index 7a7aa26e..af3125bb 100644
--- a/tests/exportfunc3.sub
+++ b/tests/exportfunc3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test function names that cannot be exported
unset foo # remove from environment if necessary
diff --git a/tests/extglob.tests b/tests/extglob.tests
index 32a6569f..4cb671a8 100644
--- a/tests/extglob.tests
+++ b/tests/extglob.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test the ksh-like extended globbing features: [!@*?+](patlist)
shopt -s extglob
diff --git a/tests/extglob1.sub b/tests/extglob1.sub
index bf65a9ea..c73b1eae 100644
--- a/tests/extglob1.sub
+++ b/tests/extglob1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
MYDIR=$PWD
: ${TMPDIR:=/tmp}
diff --git a/tests/extglob1a.sub b/tests/extglob1a.sub
index 686dab74..14703862 100644
--- a/tests/extglob1a.sub
+++ b/tests/extglob1a.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
shopt -s extglob
TESTDIR=${TMPDIR:-/tmp}/eglob-test-$$
diff --git a/tests/extglob2.tests b/tests/extglob2.tests
index f35c3e8b..187253b9 100755..100644
--- a/tests/extglob2.tests
+++ b/tests/extglob2.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
#
# More ksh-like extended globbing tests, cribbed from zsh-3.1.5
#
diff --git a/tests/extglob3.sub b/tests/extglob3.sub
index 3f51c40c..bf5d2630 100644
--- a/tests/extglob3.sub
+++ b/tests/extglob3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
shopt -s extglob
DIR=$TMPDIR/extglob-$$
mkdir $DIR
diff --git a/tests/extglob3.tests b/tests/extglob3.tests
index 60454a27..56f8b397 100644
--- a/tests/extglob3.tests
+++ b/tests/extglob3.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
shopt -s extglob
[[ ab/../ == @(ab|+([^/]))/..?(/) ]] && echo match 1
diff --git a/tests/extglob4.sub b/tests/extglob4.sub
index 2b4c53c9..5369cd69 100644
--- a/tests/extglob4.sub
+++ b/tests/extglob4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
LANG=C
LC_ALL=C
diff --git a/tests/extglob5.sub b/tests/extglob5.sub
index d400f839..580229b8 100644
--- a/tests/extglob5.sub
+++ b/tests/extglob5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# globignore extglob patterns containing colons -- problem until bash-4.2
: ${TMPDIR:=/tmp}
diff --git a/tests/func.right b/tests/func.right
index 70bf123b..f4db4d16 100644
--- a/tests/func.right
+++ b/tests/func.right
@@ -147,23 +147,23 @@ expect 20
20
expect 5 20
5 20
-expect 5 30
-5 30
+expect 5 20
+5 20
expect 2 40
2 40
expect 5 20
5 20
-./func4.sub: line 10: foo: maximum function nesting level exceeded (100)
+./func4.sub: line 23: foo: maximum function nesting level exceeded (100)
1
after: f = 100
-./func4.sub: line 10: foo: maximum function nesting level exceeded (100)
+./func4.sub: line 23: foo: maximum function nesting level exceeded (100)
1
after: f = 100
7
after FUNCNEST reset: f = 201
7
after FUNCNEST unset: f = 201
-./func4.sub: line 10: foo: maximum function nesting level exceeded (20)
+./func4.sub: line 23: foo: maximum function nesting level exceeded (20)
1
after FUNCNEST assign: f = 38
5
diff --git a/tests/func.tests b/tests/func.tests
index 8701c2ad..fffe3d2b 100644
--- a/tests/func.tests
+++ b/tests/func.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
a()
{
x=$((x - 1))
diff --git a/tests/func1.sub b/tests/func1.sub
index 345645fd..f7e84f46 100644
--- a/tests/func1.sub
+++ b/tests/func1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
#
# Test that redirections attached to shell functions are printed correctly.
# This was a bug in all bash versions before bash-2.04.
diff --git a/tests/func2.sub b/tests/func2.sub
index 41a3844b..9caabfcb 100644
--- a/tests/func2.sub
+++ b/tests/func2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
funca() (
echo func-a
)
diff --git a/tests/func3.sub b/tests/func3.sub
index 9d3d0694..5c0eac2d 100644
--- a/tests/func3.sub
+++ b/tests/func3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
#
# test some posix-mode-specific function behavior
#
@@ -23,7 +36,7 @@ echo expect 5 20
func
echo $? $var
-echo expect 5 30
+echo expect 5 20
var=30 func
echo $? $var
diff --git a/tests/func4.sub b/tests/func4.sub
index 9c9c1b42..69f15e46 100644
--- a/tests/func4.sub
+++ b/tests/func4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test FUNCNEST functionality -- bash-4.2
FUNCNEST=100
diff --git a/tests/getopts.right b/tests/getopts.right
index fff9729f..599d830a 100644
--- a/tests/getopts.right
+++ b/tests/getopts.right
@@ -1,9 +1,9 @@
-getopts: usage: getopts optstring name [arg]
+getopts: usage: getopts optstring name [arg ...]
2
-getopts: usage: getopts optstring name [arg]
+getopts: usage: getopts optstring name [arg ...]
2
-./getopts.tests: line 10: getopts: -a: invalid option
-getopts: usage: getopts optstring name [arg]
+./getopts.tests: line 23: getopts: -a: invalid option
+getopts: usage: getopts optstring name [arg ...]
-a specified
-b bval specified
remaining args: one two three
@@ -52,7 +52,7 @@ remaining args:
-a specified
remaining args:
0
-./getopts7.sub: line 4: getopts: `opt-var': not a valid identifier
+./getopts7.sub: line 17: getopts: `opt-var': not a valid identifier
remaining args:
opt: x
opt: y
@@ -61,7 +61,7 @@ opt: b
opt: c
opt: z
$1 = a
-./getopts10.sub: line 3: OPTARG: readonly variable
+./getopts10.sub: line 16: OPTARG: readonly variable
OPTARG = x = ?
unset x = ?
declare -r RO="foo"
diff --git a/tests/getopts.tests b/tests/getopts.tests
index d54190cc..06cc29a2 100644
--- a/tests/getopts.tests
+++ b/tests/getopts.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# getopts tests
# this should fail
getopts
diff --git a/tests/getopts1.sub b/tests/getopts1.sub
index df0a342e..5145879a 100644
--- a/tests/getopts1.sub
+++ b/tests/getopts1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
aflag=
bflag=
diff --git a/tests/getopts10.sub b/tests/getopts10.sub
index 84bacf8f..cc8acb0c 100644
--- a/tests/getopts10.sub
+++ b/tests/getopts10.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- -a bb
readonly OPTARG
getopts :x x
diff --git a/tests/getopts2.sub b/tests/getopts2.sub
index d91fd26a..6bb8af54 100644
--- a/tests/getopts2.sub
+++ b/tests/getopts2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
aflag=
bflag=
diff --git a/tests/getopts3.sub b/tests/getopts3.sub
index 2d8b3162..6769c491 100644
--- a/tests/getopts3.sub
+++ b/tests/getopts3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
aflag=
bflag=
diff --git a/tests/getopts4.sub b/tests/getopts4.sub
index 9cd5aef4..5fbe9548 100644
--- a/tests/getopts4.sub
+++ b/tests/getopts4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
aflag=
bflag=
diff --git a/tests/getopts5.sub b/tests/getopts5.sub
index 874b2810..bf523107 100644
--- a/tests/getopts5.sub
+++ b/tests/getopts5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
#Time-stamp: <95/06/07 07:40:40 hrue@imf.unit.no>
getop () {
diff --git a/tests/getopts6.sub b/tests/getopts6.sub
index 75d768c6..d969ecef 100644
--- a/tests/getopts6.sub
+++ b/tests/getopts6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
aflag=
bflag=
diff --git a/tests/getopts7.sub b/tests/getopts7.sub
index a20a6df1..de7d7a65 100644
--- a/tests/getopts7.sub
+++ b/tests/getopts7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
aflag=
bflag=
diff --git a/tests/getopts9.sub b/tests/getopts9.sub
index fafb0670..f7dcabce 100644
--- a/tests/getopts9.sub
+++ b/tests/getopts9.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
f()
{
OPTIND=4
diff --git a/tests/glob.right b/tests/glob.right
index 1ead7b61..94966905 100644
--- a/tests/glob.right
+++ b/tests/glob.right
@@ -20,16 +20,22 @@ ok 1
[a
[[:alpha:]
ok 2
+ok 2.1
ok 3
+ok 4
== LANG=en_US.UTF-8 ==
[[:alpha:]
ok 1
[a
[[:alpha:]
ok 2
+ok 2.1
ok 3
+ok 4
invalid character class
== LANG=C ==
+p
+p
ok 1
ok 2
ok 3
@@ -37,6 +43,8 @@ ok 4
ok 5
ok 6
== LANG=en_US.UTF-8 ==
+p
+p
ok 1
ok 2
ok 3
@@ -57,10 +65,62 @@ ok 3
ok 4
ok 5
argv[1] = <a\?>
-a?
+a\?
argv[1] = <a\?>
-a?
-aa
+a\?
+a\a
+<define\/\
+/>
+./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
+./tmp/a/b/c
+./tmp\/a/b/c
+./tm[p]\/a/b/c
+./tmp/a/b/c
+argv[1] = <./tmp/a/*>
+argv[1] = <./tmp/a/*>
+argv[1] = <./tmp/a/b/c>
+argv[1] = <./tmp/a/*>
+argv[1] = <./tmp/a/b/c>
+argv[1] = <./t\mp/a/*>
+argv[1] = <./tmp/a/b/c>
+argv[1] = <./tmp/a/>
+argv[1] = <./tmp/a/b/>
+argv[1] = <./t\mp/a/>
+argv[1] = <./t\mp/a/b/>
+argv[1] = <./tmp/a/*>
+argv[1] = <./tmp/a/b/c>
+argv[1] = <./tmp/a>
+argv[1] = <./tmp/a/b*>
+argv[1] = <./tmp/a>
+argv[1] = <./tmp/a/b*>
+argv[1] = <./tmp/>
+argv[1] = <\$foo>
+argv[2] = <\$foo>
+argv[1] = <mixed\$foo/>
+<abcdefg>
+<\.>
+*abc.c
+searchable/\.
+searchable/\./.
+readable/\.
+readable/\./.
+searchable/\.
+readable/\.
+searchable/.
+searchable/.
+searchable/.
+1: [qwe/qwe]
+2: [qwe/
+3: [qwe/]
+4:
+5: [qwe/
+6:
+a\*b
+a\*b*
+é/*
+é/*
argv[1] = <a>
argv[2] = <abc>
argv[3] = <abd>
@@ -75,7 +135,7 @@ argv[2] = <abc>
argv[3] = <abd>
argv[4] = <abe>
tmp/l1 tmp/l2 tmp/*4 tmp/l3
-./glob.tests: line 47: no match: tmp/*4
+./glob.tests: line 65: no match: tmp/*4
argv[1] = <bdir/>
argv[1] = <*>
argv[1] = <a*>
diff --git a/tests/glob.tests b/tests/glob.tests
index 01913bbe..b35d7336 100644
--- a/tests/glob.tests
+++ b/tests/glob.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
export LC_COLLATE=C
#
# test the shell globbing
@@ -12,6 +25,11 @@ ${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
MYDIR=$PWD # save where we are
diff --git a/tests/glob1.sub b/tests/glob1.sub
index 6b3b8ad1..27c216ba 100644
--- a/tests/glob1.sub
+++ b/tests/glob1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# bash-2.01.1 failed this test
: ${TMPDIR:=/var/tmp}
diff --git a/tests/glob2.sub b/tests/glob2.sub
index d33013b6..cabc3502 100644
--- a/tests/glob2.sub
+++ b/tests/glob2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
. ./test-glue-functions
var='ab\'
diff --git a/tests/glob3.sub b/tests/glob3.sub
index 378234db..662c65e9 100644
--- a/tests/glob3.sub
+++ b/tests/glob3.sub
@@ -1,5 +1,24 @@
+# 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/>.
+#
: ${TMPDIR:=/var/tmp}
-cd $TMPDIR
+
+TESTDIR=${TMPDIR}/glob-test-$$
+mkdir ${TESTDIR}
+cd $TESTDIR || {
+ echo "$TESTDIR: cannot cd" >&2
+ exit 1
+}
matchfunc()
{
@@ -25,10 +44,21 @@ matchfunc()
*) echo bad 2;;
esac
+ case x in
+ [[:aeioux:]) echo bad 2.1 ;;
+ *) echo ok 2.1 ;;
+ esac
+
case [x in
[[:alpha:]) echo bad 3;;
*) echo ok 3;;
esac
+
+ # unclosed bracket char class expression just matches against ":alpha"
+ case a in
+ [[:alpha]) echo ok 4;;
+ *) echo bad 4;;
+ esac
}
echo invalid bracket expression
@@ -44,6 +74,12 @@ matchfunc()
{
echo == LANG=$LANG ==
+ touch p
+ # quoted character classes work as if they were unquoted now
+ echo [[:alpha:]]
+ echo [[:"alpha":]]
+ rm -f p
+
case a] in
[[:aleph:]]) echo bad 1;;
*) echo ok 1;;
@@ -59,9 +95,10 @@ matchfunc()
*) echo ok 3;;
esac
- case a in
- [[:"alpha":]]) echo bad 4;;
- *) echo ok 4;;
+ # Posix says quoted character class names work now
+ case x in
+ [[:"alpha":]]) echo ok 4;;
+ *) echo bad 4;;
esac
case a in
@@ -121,3 +158,6 @@ matchfunc
export LANG=en_US.UTF-8
matchfunc
+
+cd $OLDPWD
+rm -rf $TESTDIR
diff --git a/tests/glob4.sub b/tests/glob4.sub
index 378b5a92..779c8540 100644
--- a/tests/glob4.sub
+++ b/tests/glob4.sub
@@ -1,4 +1,23 @@
-trap "rm 'a?' aa" EXIT
+# 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/>.
+#
+: ${TMPDIR:=/var/tmp}
+
+FN=$TMPDIR/bash-glob.$$
+mkdir $FN || { echo "glob4.sub: cannot mkdir $FN" >&2 ; exit 1; }
+builtin cd $FN || { echo "glob4.sub: cannot change directory to $FN" >&2 ; exit 1; }
+rm -f *
+
touch 'a?' aa
set -- a \?; IFS=\\; var=$*;
@@ -11,3 +30,12 @@ printf "%s\n" ${var}
var='a\a'
printf "%s\n" ${var}
+
+# shell's idea of a glob pattern and libglob's idea of a glob pattern have to
+# be identical
+PRE='\/'
+printf '<%s>\n' 'define'${PRE}'\
+/'
+
+builtin cd $OLDPWD
+rm -rf $FN
diff --git a/tests/glob5.sub b/tests/glob5.sub
new file mode 100644
index 00000000..5735715d
--- /dev/null
+++ b/tests/glob5.sub
@@ -0,0 +1,76 @@
+# 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/>.
+#
+ORIGD=$PWD
+: ${TMPDIR:=/var/tmp}
+
+SD=$TMPDIR/bash-glob-$$
+[ -d $SD ] || mkdir $SD
+builtin cd $SD || { echo "glob5.sub: cannot change directory to $SD" >&2 ; exit 1; }
+mkdir tmp
+
+D=./tmp/a
+D1='./t\mp/a'
+
+mkdir -m700 ./tmp/a ./tmp/a/b
+touch ./tmp/a/b/c
+
+echo ./tmp/a/b/* "./tmp/a/"b/* "./tmp/a/b"/*
+
+chmod -r ./tmp/a
+echo ./tmp/a/b/* "./tmp/a/"b/* "./tmp/a/b"/*
+echo "./tmp/a/b"/*
+
+bs=\\
+echo ./tmp${bs}/a/b/*
+echo ./tmp${bs}/a/b/c
+echo ./tm[p]${bs}/a/b/c
+echo ./t${bs}mp/a/b/*
+
+recho "./tmp/a"/*
+recho "$D"/*
+recho "$D"/b/*
+
+recho $D/*
+recho $D/b/*
+recho $D1/*
+recho $D1/b/*
+recho $D/
+recho $D/b/
+recho $D1/
+recho $D1/b/
+
+recho ./t\mp/a/*
+recho ./t\mp/a/b/*
+
+recho ./tmp/a*
+recho ./tmp/a/b*
+recho ./t\mp/a*
+recho ./t\mp/a/b*
+
+recho ./t\mp/
+
+chmod +r ./tmp/a
+rm -rf ./tmp/a
+
+a='$foo'
+b='$bar'
+a=$(echo "$a" | sed 's/\$/\\$/g')
+
+recho $a "$a"
+recho 'mixed'$a/
+
+unset a b
+
+cd $ORIGD
+rm -rf $SD
diff --git a/tests/glob6.sub b/tests/glob6.sub
new file mode 100644
index 00000000..f26ae4d6
--- /dev/null
+++ b/tests/glob6.sub
@@ -0,0 +1,68 @@
+# 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/>.
+#
+# tests of the backslash-in-glob-patterns discussion on the austin-group ML
+
+: ${TMPDIR:=/var/tmp}
+
+ORIG=$PWD
+GLOBDIR=$TMPDIR/bash-glob-$$
+mkdir $GLOBDIR || { echo "glob6.sub: cannot make directory $GLOBDIR" >&2 ; exit 1; }
+builtin cd $GLOBDIR || { echo "glob6.sub: cannot change directory to $GLOBDIR" >&2 ; exit 1; }
+
+# does the pattern matcher allow backslashes as escape characters and remove
+# them as part of matching?
+touch abcdefg
+pat='ab\cd*'
+printf '<%s>\n' $pat
+pat='\.'
+printf '<%s>\n' $pat
+rm abcdefg
+
+# how about when escaping pattern characters?
+touch '*abc.c'
+a='\**.c'
+printf '%s\n' $a
+rm -f '*abc.c'
+
+# how about when making the distinction between readable and searchable path
+# components?
+mkdir -m a=x searchable
+mkdir -m a=r readable
+
+p='searchable/\.'
+printf "%s\n" $p
+
+p='searchable/\./.'
+printf "%s\n" $p
+
+p='readable/\.'
+printf "%s\n" $p
+
+p='readable/\./.'
+printf "%s\n" $p
+
+printf "%s\n" 'searchable/\.'
+printf "%s\n" 'readable/\.'
+
+echo */.
+
+p='*/\.'
+echo $p
+
+echo */'.'
+
+rmdir searchable readable
+
+cd $ORIG
+rmdir $GLOBDIR
diff --git a/tests/glob7.sub b/tests/glob7.sub
new file mode 100644
index 00000000..0212b8e5
--- /dev/null
+++ b/tests/glob7.sub
@@ -0,0 +1,11 @@
+# according to Posix 2.13.3, a slash in a bracket expression renders that
+# bracket expression invalid
+shopt -s nullglob
+
+echo 1: [qwe/qwe]
+echo 2: [qwe/
+echo 3: [qwe/]
+
+echo 4: [qwe\/qwe]
+echo 5: [qwe\/
+echo 6: [qwe\/]
diff --git a/tests/glob8.sub b/tests/glob8.sub
new file mode 100644
index 00000000..dca54fcc
--- /dev/null
+++ b/tests/glob8.sub
@@ -0,0 +1,31 @@
+# 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/>.
+#
+: ${TMPDIR:=/var/tmp}
+
+TESTDIR=${TMPDIR}/glob-test-$$
+mkdir ${TESTDIR}
+cd $TESTDIR || {
+ echo "$TESTDIR: cannot cd" >&2
+ exit 1
+}
+
+trap 'cd $OLDPWD && rm -rf $TESTDIR' EXIT
+
+var='a\'
+touch 'a*b' 'a\*b'
+
+printf '%s\n' $var\*b*
+
+var1=a\\$'\001'
+printf '%s\n' $var1\*b*
diff --git a/tests/glob9.sub b/tests/glob9.sub
new file mode 100644
index 00000000..ef2af2bd
--- /dev/null
+++ b/tests/glob9.sub
@@ -0,0 +1,13 @@
+LANG=en_US.UTF-8 # safest
+: ${TMPDIR:=/var/tmp}
+HOME=${TMPDIR}
+
+mkdir ~/ಇಳಿಕೆಗಳು
+touch ~/ಇಳಿಕೆಗಳು/{a,b}.txt
+echo ~/ಇಳಿಕೆಗಳು/*.txt >/dev/null
+
+rm -rf ${TMPDIR}/ಇಳಿಕೆಗಳು
+
+LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
+echo é/*
+echo 'é'/*
diff --git a/tests/globstar.right b/tests/globstar.right
index 69030c41..c8211bc8 100644
--- a/tests/globstar.right
+++ b/tests/globstar.right
@@ -582,3 +582,6 @@ bar/foo/e bar/foo/f foo/a foo/b
<b/b/a/a>
<b/b/a/b>
<b/b/b/a>
+a a/aa a/ab b b/bb b/bc c
+a/ b/ c/
+a/ab b b/bb
diff --git a/tests/globstar.tests b/tests/globstar.tests
index f7efbd19..33714b4f 100644
--- a/tests/globstar.tests
+++ b/tests/globstar.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${TMPDIR:=/var/tmp}
dir=$PWD
@@ -40,3 +53,4 @@ rm -rf $GDIR
${THIS_SH} ./globstar1.sub
${THIS_SH} ./globstar2.sub
+${THIS_SH} ./globstar3.sub
diff --git a/tests/globstar1.sub b/tests/globstar1.sub
index 8b9e36dc..7097f5d4 100644
--- a/tests/globstar1.sub
+++ b/tests/globstar1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
shopt -s globstar
wdir=$PWD
diff --git a/tests/globstar2.sub b/tests/globstar2.sub
index 4e1a0245..ccf413b1 100644
--- a/tests/globstar2.sub
+++ b/tests/globstar2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
olddir=$PWD
: ${TMPDIR:=/var/tmp}
EMPTY=$TMPDIR/empty
diff --git a/tests/globstar3.sub b/tests/globstar3.sub
new file mode 100644
index 00000000..771d9061
--- /dev/null
+++ b/tests/globstar3.sub
@@ -0,0 +1,37 @@
+# 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/>.
+#
+olddir=$PWD
+: ${TMPDIR:=/var/tmp}
+
+SCRATCH=${TMPDIR}/scratch-$$
+rm -rf $SCRATCH
+mkdir $SCRATCH || exit 1
+
+cd $SCRATCH
+
+mkdir a b
+touch a/aa a/ab
+touch b/bb b/bc
+
+ln -s a c
+
+shopt -s globstar
+
+echo **
+echo **/
+
+echo **/*b
+
+cd "$olddir"
+rm -rf $SCRATCH
diff --git a/tests/heredoc.right b/tests/heredoc.right
index f6541dca..f6e53bea 100644
--- a/tests/heredoc.right
+++ b/tests/heredoc.right
@@ -1,3 +1,11 @@
+a
+b
+c
+a
+$PS4
+
+
+
there
one - alpha
two - beta
@@ -59,13 +67,13 @@ qux
bar
qux
abc def geh
-./heredoc3.sub: line 10: warning: here-document at line 8 delimited by end-of-file (wanted `EOF')
+./heredoc3.sub: line 23: warning: here-document at line 21 delimited by end-of-file (wanted `EOF')
= here is the text =
-./heredoc3.sub: line 16: warning: here-document at line 14 delimited by end-of-file (wanted `EOF')
+./heredoc3.sub: line 29: warning: here-document at line 27 delimited by end-of-file (wanted `EOF')
this paren ) is not a problem
-./heredoc3.sub: line 22: warning: here-document at line 20 delimited by end-of-file (wanted `EOF')
+./heredoc3.sub: line 35: warning: here-document at line 33 delimited by end-of-file (wanted `EOF')
these balanced parens ( ) are not a problem
-./heredoc3.sub: line 28: warning: here-document at line 26 delimited by end-of-file (wanted `EOF')
+./heredoc3.sub: line 41: warning: here-document at line 39 delimited by end-of-file (wanted `EOF')
quoted balanced parens \( ) are not a problem either
more text in a subshell
some more text in a different subshell
@@ -82,8 +90,8 @@ end helloEND
hello
\END
end hello<NL>\END
-./heredoc3.sub: line 85: warning: here-document at line 83 delimited by end-of-file (wanted `EOF')
-./heredoc3.sub: line 86: syntax error: unexpected end of file
+./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
heredoc1
EOF
Ok:0
@@ -93,6 +101,6 @@ argv[1] = <two>
argv[2] = <threefi>
argv[3] = <ve>
comsub here-string
-./heredoc.tests: line 105: warning: here-document at line 103 delimited by end-of-file (wanted `EOF')
+./heredoc.tests: line 149: warning: here-document at line 147 delimited by end-of-file (wanted `EOF')
hi
there
diff --git a/tests/heredoc.tests b/tests/heredoc.tests
index 303949f4..430302f5 100644
--- a/tests/heredoc.tests
+++ b/tests/heredoc.tests
@@ -1,5 +1,46 @@
-# check order and content of multiple here docs
+# 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/>.
+#
+# basics
+cat <<EOF
+a
+b
+c
+EOF
+read x <<EOF
+a
+b
+c
+EOF
+echo "$x"
+read x y <<\EOF
+$PS4
+EOF
+echo "$x"
+
+# empty here-documents
+read x <<EOF
+EOF
+echo "$x"
+read x <<\EOF
+EOF
+echo "$x"
+read x <<EOF
+$empty
+EOF
+echo "$x"
+# check order and content of multiple here docs
cat << EOF1 << EOF2
hi
EOF1
@@ -93,6 +134,9 @@ ${THIS_SH} ./heredoc2.sub
${THIS_SH} ./heredoc3.sub
${THIS_SH} ./heredoc4.sub
+# heredoc tests that use different size documents to test pipe implementation
+${THIS_SH} ./heredoc5.sub
+
echo $(
cat <<< "comsub here-string"
)
diff --git a/tests/heredoc1.sub b/tests/heredoc1.sub
index 3f85ead7..34977c51 100644
--- a/tests/heredoc1.sub
+++ b/tests/heredoc1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
foo()
{
echo
diff --git a/tests/heredoc3.sub b/tests/heredoc3.sub
index a5a2fbc0..efbdf7d4 100644
--- a/tests/heredoc3.sub
+++ b/tests/heredoc3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
SAVEPWD=$PWD
: ${TMPDIR:=/tmp}
cd $TMPDIR || echo "heredoc3.sub: cannot cd to $TMPDIR" >&2
diff --git a/tests/heredoc5.sub b/tests/heredoc5.sub
new file mode 100644
index 00000000..d7b5926d
--- /dev/null
+++ b/tests/heredoc5.sub
@@ -0,0 +1,41 @@
+# 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 here documents for sizes > 65536 (max pipe capacity I've seen),
+# 4096 < size < 65536 (for smaller pipe capacities)
+# 512 < size < 4096 (PIPE_BUF)
+#
+# There are tests in other scripts for here documents shorter than 512 bytes
+#
+# This should return the same results regardless of the pipe capacity
+
+: ${TMPDIR:=/tmp}
+FILENAME=${TMPDIR}/catfile-$$
+
+catfile()
+{
+ cat <<- EOF > $FILENAME
+ $(cat $1)
+EOF
+ cmp $FILENAME $1
+ rm -f $FILENAME
+}
+
+
+if [ -f $BUILD_DIR/y.tab.c ]; then
+ catfile $BUILD_DIR/y.tab.c
+else
+ catfile ../y.tab.c
+fi
+catfile ${BUILD_DIR}/config.h
+catfile ${BUILD_DIR}/version.h
diff --git a/tests/herestr.right b/tests/herestr.right
index 03f38ed6..4ac2cc65 100644
--- a/tests/herestr.right
+++ b/tests/herestr.right
@@ -1,3 +1,10 @@
+alpha
+beta
+4
+4
+
+
+
abcde
yo
hot damn
diff --git a/tests/herestr.tests b/tests/herestr.tests
index 607f85ee..6f4c74c2 100644
--- a/tests/herestr.tests
+++ b/tests/herestr.tests
@@ -1,3 +1,36 @@
+# 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/>.
+#
+# basics
+read x <<<"alpha"
+echo "$x"
+read x <<<beta
+echo "$x"
+X=4
+read x <<<$X
+echo "$x"
+read x <<<"$X"
+echo "$x"
+unset X
+
+# empty here-strings
+read x <<<""
+echo "$x"
+read x <<<"$empty"
+echo "$x"
+read x <<<$empty
+echo "$x"
+
a=hot
b=damn
f1()
diff --git a/tests/histexp.right b/tests/histexp.right
index 9dc592cb..341252c0 100644
--- a/tests/histexp.right
+++ b/tests/histexp.right
@@ -1,5 +1,5 @@
echo $BASH_VERSION
-./histexp.tests: line 24: history: !!:z: history expansion failed
+./histexp.tests: line 37: 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
@@ -202,7 +202,7 @@ d
!
e
! !
-./histexp4.sub: line 20: !': event not found
+./histexp4.sub: line 33: !': event not found
/tmp/Step1
echo /$(echo tmp)/Step1
/tmp/Step1
@@ -240,3 +240,7 @@ echo two
1 echo two
2 for f in a b c; do echo echo two; done
3 history
+a
+echo !!
+--between--
+echo !!
diff --git a/tests/histexp.tests b/tests/histexp.tests
index 5ae925e1..91a36f23 100644
--- a/tests/histexp.tests
+++ b/tests/histexp.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
LC_ALL=C
LANG=C
trap 'rm $TMPDIR/newhistory' 0
@@ -142,3 +155,4 @@ ${THIS_SH} ./histexp3.sub
${THIS_SH} ./histexp4.sub
${THIS_SH} ./histexp5.sub
${THIS_SH} ./histexp6.sub
+${THIS_SH} ./histexp7.sub
diff --git a/tests/histexp1.sub b/tests/histexp1.sub
index a5948f1e..cc2c5d1d 100644
--- a/tests/histexp1.sub
+++ b/tests/histexp1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
LC_ALL=C
LANG=C
diff --git a/tests/histexp3.sub b/tests/histexp3.sub
index 495f0952..4962436d 100644
--- a/tests/histexp3.sub
+++ b/tests/histexp3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
HISTFILE=${TMPDIR}/bashhist-$$
set -o history
diff --git a/tests/histexp4.sub b/tests/histexp4.sub
index ddc3bb3c..9cae0e37 100644
--- a/tests/histexp4.sub
+++ b/tests/histexp4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
HISTFILE=$TMPDIR/bashhist-$$
set -o history
diff --git a/tests/histexp5.sub b/tests/histexp5.sub
index 0fe62fe4..9e6d01bc 100644
--- a/tests/histexp5.sub
+++ b/tests/histexp5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -o history
set -o histexpand
diff --git a/tests/histexp6.sub b/tests/histexp6.sub
index 00610b07..d52e5ea8 100644
--- a/tests/histexp6.sub
+++ b/tests/histexp6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
unset HISTIGNORE
HISTFILE=$TMPDIR/bashhist-$$
diff --git a/tests/histexp7.sub b/tests/histexp7.sub
new file mode 100644
index 00000000..8822205e
--- /dev/null
+++ b/tests/histexp7.sub
@@ -0,0 +1,18 @@
+# make sure history expansion doesn't take place while parsing command
+# substitutions
+
+set -o history
+set -o histexpand
+echo a
+
+echo $( cat <<EOF
+echo !!
+EOF
+)
+
+echo --between--
+
+cat <( cat <<'EOF'
+echo !!
+EOF
+)
diff --git a/tests/history.right b/tests/history.right
index d83fc718..379de48b 100644
--- a/tests/history.right
+++ b/tests/history.right
@@ -1,7 +1,7 @@
-./history.tests: line 4: history: -x: invalid option
+./history.tests: line 17: history: -x: invalid option
history: usage: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
-./history.tests: line 6: history: cannot use more than one of -anrw
-./history.tests: line 9: fc: -v: invalid option
+./history.tests: line 19: history: cannot use more than one of -anrw
+./history.tests: line 22: fc: -v: invalid option
fc: usage: fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]
1 for i in one two three; do echo $i; done
2 /bin/sh -c 'echo this is $0'
@@ -97,17 +97,17 @@ line 2 for history
6 HISTFILE=$TMPDIR/newhistory
7 echo displaying \$HISTFILE after history -a
8 cat $HISTFILE
-./history.tests: line 76: fc: history specification out of range
- 14 set -H
+./history.tests: line 90: fc: no command found
15 echo line 2 for history
16 unset HISTSIZE
17 unset HISTFILE
+ 18 # now an out-of-range error because of the one=two not found in history
aa ab ac
echo xx xb xc
xx xb xc
echo 44 48 4c
44 48 4c
-./history.tests: line 91: fc: no command found
+./history.tests: line 105: fc: no command found
aa
bb
cc
@@ -140,9 +140,9 @@ three
one
two
three
-5.0
+5.1
echo ${BASH_VERSION%\.*}
-5.0
+5.1
echo ${BASH_VERSION%\.*}
a
b
@@ -167,14 +167,100 @@ i
4 echo g
5 echo h
-./history3.sub: line 27: history: 16: history position out of range
-./history3.sub: line 28: history: 200: history position out of range
-./history3.sub: line 29: history: -20: history position out of range
-./history3.sub: line 30: history: -50: history position out of range
-./history3.sub: line 31: history: 5-0xaf: history position out of range
+./history3.sub: line 40: history: 16: history position out of range
+./history3.sub: line 41: history: 200: history position out of range
+./history3.sub: line 42: history: -20: history position out of range
+./history3.sub: line 43: history: -50: history position out of range
+./history3.sub: line 44: history: 5-0xaf: history position out of range
1 echo a
2 echo e
3 echo f
4 echo g
5 echo h
+
+0
+1
+2
+(left
+mid
+right)
+A
+B
+
+(left
+mid
+right)
+A
+B
+
+(left
+mid
+right)
+A
+B
+
+0
+1
+2
+(left
+mid
+right)
+A
+B
+(left
+mid
+right)
+A
+B
+
+0
+1
+2
+(left
+mid
+right)
+A
+B
+(left
+mid
+right)
+A
+B
+a
+b
+./history5.sub: line 24: fc: history specification out of range
+./history5.sub: line 25: fc: no command found
+1 echo a
+2 echo b
+3 fc -0 # error
+4 fc -s -0 # error
+c
+6 echo c
+8 fc -l -0
+d
+echo d
+d
+a
+b
+c
+d
+e
+f
+4 echo d
+5 echo e
+6 echo f
+out of range 1
+6 echo f
+7 fc -l
+8 echo out of range 1
+out of range 2
+8 echo out of range 1
+9 fc -l 502 498
+10 echo out of range 2
+out of range 3
+10 echo out of range 2
+11 fc -l 498 502
+12 echo out of range 3
+out of range 4
+13 fc -l 1 99
diff --git a/tests/history.tests b/tests/history.tests
index 4001bd6c..53321f05 100644
--- a/tests/history.tests
+++ b/tests/history.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
trap 'rm $TMPDIR/newhistory' 0
# bad options
@@ -73,6 +86,7 @@ unset HISTFILE
fc -l 4
fc -l 4 8
+# now an out-of-range error because of the one=two not found in history
fc -l one=two three=four 502
history 4
@@ -114,3 +128,5 @@ rm -f $TMPDIR/foohist-*
${THIS_SH} ./history2.sub
${THIS_SH} ./history3.sub
+${THIS_SH} ./history4.sub
+${THIS_SH} ./history5.sub
diff --git a/tests/history1.sub b/tests/history1.sub
index 091b1edc..b67a0efa 100644
--- a/tests/history1.sub
+++ b/tests/history1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
trap 'rm -f $HISTFILE' 0 1 2 3 6 15
HISTFILE=$TMPDIR/foohist-$$
diff --git a/tests/history3.sub b/tests/history3.sub
index 8722666c..d8a22038 100644
--- a/tests/history3.sub
+++ b/tests/history3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${TMPDIR:=/tmp}
set -o history
diff --git a/tests/history4.sub b/tests/history4.sub
new file mode 100644
index 00000000..651374cf
--- /dev/null
+++ b/tests/history4.sub
@@ -0,0 +1,47 @@
+# 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/>.
+#
+HISTFILE=$TMPDIR/newhistory-$$
+export HISTFILE
+
+trap 'rm -f $HISTFILE' EXIT
+
+HISTSIZE=32
+HISTFILESIZE=32
+echo
+set -o history
+history -c
+echo 0
+echo 1
+echo 2
+echo "(left
+mid
+right)"
+echo A
+echo B
+history -w
+set +o history
+
+echo
+printf $'HISTFILE=\n\cRleft\cO\cO\cO\cO\n' | HISTSIZE= ${THIS_SH} --norc -i 2>/dev/null
+echo
+printf $'HISTFILE=\n\cRleft\cO\cO\cO\cO\n' | HISTSIZE=8 ${THIS_SH} --norc -i 2>/dev/null
+
+input="$(cat $HISTFILE)
+"$'\cP\cP\cP\cO\cO
+'
+
+echo
+printf "$input" | HISTSIZE= HISTFILE= ${THIS_SH} --norc -i 2>/dev/null
+echo
+printf "$input" | HISTSIZE=6 HISTFILE= ${THIS_SH} --norc -i 2>/dev/null
diff --git a/tests/history5.sub b/tests/history5.sub
new file mode 100644
index 00000000..245c28d0
--- /dev/null
+++ b/tests/history5.sub
@@ -0,0 +1,57 @@
+# 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/>.
+#
+
+trap 'rm -f "$OUT"' 0 1 2 3 6 15
+
+HISTFILE=$TMPDIR/fchist-$$ ; OUT=$HISTFILE
+unset HISTIGNORE HISTCONTROL
+set -o history
+
+echo a
+echo b
+
+fc -0 # error
+fc -s -0 # error
+
+fc -l
+
+echo c
+fc -l 0
+fc -l -0
+
+echo d
+fc -s 0
+
+HISTSIZE=4
+history -c
+
+echo a
+echo b
+echo c
+echo d
+echo e
+echo f
+fc -l
+
+echo out of range 1
+fc -l 502 498
+echo out of range 2
+fc -l 498 502
+echo out of range 3
+fc -l 1 99
+# other out-of-range behavior for future work
+echo out of range 4
+fc -l -20 -40
+
+unset HISTFILE # suppress writing history file
diff --git a/tests/ifs-posix.tests b/tests/ifs-posix.tests
index cf9a8987..21a90636 100644
--- a/tests/ifs-posix.tests
+++ b/tests/ifs-posix.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# Usage: $SHELL ifs.sh
#
# This script generates 6856 tests for the set(1) and read(1)
diff --git a/tests/ifs.tests b/tests/ifs.tests
index 71769005..27f27dd6 100644
--- a/tests/ifs.tests
+++ b/tests/ifs.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
OIFS="$IFS"
IFS=":$IFS"
eval foo="a:b:c"
diff --git a/tests/intl.tests b/tests/intl.tests
index 5c15b47e..c3000fc7 100644
--- a/tests/intl.tests
+++ b/tests/intl.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
export LC_ALL=en_US.UTF-8
a=$'\303\251'
diff --git a/tests/intl3.sub b/tests/intl3.sub
index 650000e9..56c86780 100644
--- a/tests/intl3.sub
+++ b/tests/intl3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
. ./test-glue-functions
# more tests to make sure that IFS splits on characters, not bytes
diff --git a/tests/invert.tests b/tests/invert.tests
index 8393d95a..f339d41f 100644
--- a/tests/invert.tests
+++ b/tests/invert.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# tests of return value inversion
# placeholder for future expansion
diff --git a/tests/iquote.tests b/tests/iquote.tests
index a1e63622..8411c8ab 100644
--- a/tests/iquote.tests
+++ b/tests/iquote.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# bug in bash up to and including bash-3.0 (including patches)
#
# problem is conflict between CTLNUL used internally to denote quoted null
diff --git a/tests/iquote1.sub b/tests/iquote1.sub
index 1a8a35c0..685a80ea 100644
--- a/tests/iquote1.sub
+++ b/tests/iquote1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# Problems with variables that expand to 0x7f and quoted nulls in the same
# expansion -- affects bash versions 4.0-post 4.2
a=x
diff --git a/tests/jobs.right b/tests/jobs.right
index 0e9d1d19..5d03b76b 100644
--- a/tests/jobs.right
+++ b/tests/jobs.right
@@ -27,46 +27,55 @@ i killed it
12
[1]- Running sleep 20 &
[3]+ Running sleep 20 &
+5: ok 1
+./jobs5.sub: line 40: wait: %8: no such job
+2: ok 2
+2: ok 3
child1 exit status 0
+[1]+ Running sleep 20 &
+./jobs7.sub: line 5: fg: no current jobs
+[1]+ Running sleep 20 &
0
-./jobs.tests: line 25: wait: %1: no such job
-./jobs.tests: line 30: fg: no job control
+./jobs.tests: line 40: wait: %1: no such job
+./jobs.tests: line 45: fg: no job control
wait-for-pid
wait-errors
-./jobs.tests: line 43: wait: `1-1': not a pid or valid job spec
-./jobs.tests: line 44: wait: `-4': not a pid or valid job spec
+./jobs.tests: line 58: wait: `1-1': not a pid or valid job spec
+./jobs.tests: line 59: wait: `-4': not a pid or valid job spec
wait-for-background-pids
async list wait-for-background-pids
async list wait for child
forked
wait-when-no-children
+posix jobs output
+[1]+ Done sleep 1
wait-for-job
-./jobs.tests: line 66: wait: %2: no such job
+./jobs.tests: line 84: wait: %2: no such job
127
async list wait-for-job
forked
fg-bg 1
-sleep 5
+sleep 2
fg-bg 2
-sleep 5
+sleep 2
fg-bg 3
-sleep 5
+sleep 2
fg-bg 4
-sleep 5
+sleep 2
fg-bg 5
-./jobs.tests: line 93: fg: %2: no such job
-./jobs.tests: line 94: bg: job 1 already in background
+./jobs.tests: line 111: fg: %2: no such job
+./jobs.tests: line 112: bg: job 1 already in background
fg-bg 6
-./jobs.tests: line 101: fg: -s: invalid option
+./jobs.tests: line 119: fg: -s: invalid option
fg: usage: fg [job_spec]
-./jobs.tests: line 102: bg: -s: invalid option
+./jobs.tests: line 120: bg: -s: invalid option
bg: usage: bg [job_spec ...]
-./jobs.tests: line 107: disown: -s: invalid option
+./jobs.tests: line 125: disown: -s: invalid option
disown: usage: disown [-h] [-ar] [jobspec ... | pid ...]
-./jobs.tests: line 111: disown: %1: no such job
-./jobs.tests: line 114: disown: %2: no such job
+./jobs.tests: line 129: disown: %1: no such job
+./jobs.tests: line 132: disown: %2: no such job
wait-for-non-child
-./jobs.tests: line 117: wait: pid 1 is not a child of this shell
+./jobs.tests: line 135: wait: pid 1 is not a child of this shell
127
3 -- 1 2 3 -- 1 - 2 - 3
[1] Running sleep 300 &
@@ -76,8 +85,8 @@ running jobs:
[1] Running sleep 300 &
[2]- Running sleep 350 &
[3]+ Running sleep 400 &
-./jobs.tests: line 134: kill: %4: no such job
-./jobs.tests: line 136: jobs: %4: no such job
+./jobs.tests: line 152: kill: %4: no such job
+./jobs.tests: line 154: jobs: %4: no such job
current job:
[3]+ Running sleep 400 &
previous job:
@@ -105,5 +114,5 @@ after kill -STOP, backgrounding %3:
killing...
done
after KILL -STOP, foregrounding %1
-sleep 10
+sleep 4
done
diff --git a/tests/jobs.tests b/tests/jobs.tests
index 3c2eef31..dacdc15d 100644
--- a/tests/jobs.tests
+++ b/tests/jobs.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test out %+, jobs -p, and $! agreement in a subshell first
${THIS_SH} ./jobs1.sub
@@ -18,6 +31,8 @@ ${THIS_SH} ./jobs5.sub
# test out wait -f framework
${THIS_SH} ./jobs6.sub
+${THIS_SH} ./jobs7.sub
+
jobs
echo $?
@@ -36,7 +51,7 @@ wait # make sure we reap the processes while stderr is still redirected
exec 2>&5
echo wait-for-pid
-sleep 10 &
+sleep 4 &
wait $!
echo wait-errors
@@ -44,52 +59,55 @@ wait 1-1
wait -- -4
echo wait-for-background-pids
-sleep 5 &
-sleep 8 &
+sleep 2 &
+sleep 4 &
wait
echo async list wait-for-background-pids
-sleep 5 & sleep 8 &
+sleep 2 & sleep 4 &
wait
echo async list wait for child
-sleep 5 & echo forked
+sleep 2 & echo forked
wait
echo wait-when-no-children
wait
+echo posix jobs output
+${THIS_SH} -o posix -c 'sleep 1 & P=$! ; sleep 2; jobs; wait'
+
set -m
echo wait-for-job
-sleep 5 &
+sleep 3 &
wait %2 # this should be a no-such-job error
echo $?
wait %1
echo async list wait-for-job
-sleep 5 & echo forked
+sleep 2 & echo forked
wait %1
echo fg-bg 1
-sleep 5 &
+sleep 2 &
%1
echo fg-bg 2
-sleep 5 &
+sleep 2 &
fg %%
echo fg-bg 3
-sleep 5 &
+sleep 2 &
fg %s
echo fg-bg 4
-sleep 5 &
+sleep 2 &
fg %?ee
# these next two are error cases
echo fg-bg 5
-sleep 15 &
+sleep 2 &
fg %2 # this should be a no-such-job error
bg %1 # this should be a `bg background job?' error
wait
@@ -97,7 +115,7 @@ wait
# these may someday mean to start the jobs, but not print the line
# describing the status, but for now they are errors
echo fg-bg 6
-sleep 5 &
+sleep 2 &
fg -s %1
bg -s %1
wait
@@ -140,7 +158,7 @@ echo previous job:
jobs %-
kill -STOP %2
-sleep 5 # give time for the shell to get the stop notification
+sleep 3 # give time for the shell to get the stop notification
echo after kill -STOP
echo running jobs:
jobs -r
@@ -164,7 +182,7 @@ echo stopped jobs:
jobs -s
kill -STOP %3
-sleep 5 # give time for the shell to get the stop notification
+sleep 3 # give time for the shell to get the stop notification
echo after kill -STOP, backgrounding %3:
bg %3
@@ -182,9 +200,9 @@ echo done
exec 2>&5
-sleep 10 &
+sleep 4 &
kill -STOP %1
-sleep 5 # give time for the shell to get the stop notification
+sleep 2 # give time for the shell to get the stop notification
echo after KILL -STOP, foregrounding %1
fg %1
diff --git a/tests/jobs1.sub b/tests/jobs1.sub
index 53f66cc6..84919d9b 100644
--- a/tests/jobs1.sub
+++ b/tests/jobs1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# make sure that jobs -p, %+, and $! all agree
set -m
sleep 60 &
diff --git a/tests/jobs3.sub b/tests/jobs3.sub
index 6efd58b0..1337fc12 100644
--- a/tests/jobs3.sub
+++ b/tests/jobs3.sub
@@ -1,4 +1,17 @@
-#! /bin/bash
+# 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/>.
+#
+
NJOB=8
i=0
diff --git a/tests/jobs4.sub b/tests/jobs4.sub
index 898b449b..7ecd7123 100644
--- a/tests/jobs4.sub
+++ b/tests/jobs4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test being able to use job control notation in jobs/kill/wait without
# job control active, as the SUS requires
diff --git a/tests/jobs5.sub b/tests/jobs5.sub
index 35d39816..e6ffb44e 100644
--- a/tests/jobs5.sub
+++ b/tests/jobs5.sub
@@ -1,12 +1,61 @@
+# 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/>.
+#
+
# framework to test new `wait -n' option that waits for any job to finish
set -m
sleep 20 &
-{ sleep 5; exit 12; } &
+{ sleep 2; exit 12; } &
sleep 20 &
wait -n
echo $?
jobs
+disown -a
+
+{ sleep 1 ; exit 4; } &
+{ sleep 2 ; exit 5; } & bgpid1=$!
+{ sleep 4 ; exit 6; } &
+
+wait -p wvar -n %2 %3
+case "$wvar" in
+$bgpid1) echo $?: ok 1;;
+*) echo bad 1;;
+esac
+
+{ sleep 1 ; exit 2; } & bgpid2=$!
+wait -p wvar -n %8 $!
+case $wvar in
+$bgpid2) echo $?: ok 2;;
+*) echo bad 2;;
+esac
+
+disown -a
+
+{ sleep 3; exit 1; } & { sleep 1; exit 2; } & bgpid3=$!
+{ sleep 3; exit 3; } & { sleep 3; exit 4; } &
+
+wait -n -p wpid %1 %2 %3 %4
+
+case $wpid in
+$bgpid3) echo $?: ok 3;;
+*) echo bad 3 ;;
+esac
+
+disown -a
+
+unset bgpid1 bgpid2 bgpid3
+unset wpid
diff --git a/tests/jobs7.sub b/tests/jobs7.sub
new file mode 100644
index 00000000..3e76db37
--- /dev/null
+++ b/tests/jobs7.sub
@@ -0,0 +1,6 @@
+# make sure fg in a subshell doesn't try to start a parent's job
+set -m
+sleep 20 &
+echo $(jobs)
+echo $(fg %% ; jobs)
+kill %1
diff --git a/tests/lastpipe.tests b/tests/lastpipe.tests
index 16dc8419..775e81dd 100644
--- a/tests/lastpipe.tests
+++ b/tests/lastpipe.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
binfalse()
{
$binfalse || return 1 # normalize return value
@@ -15,7 +28,7 @@ if [ -x /usr/bin/false ]; then
elif [ -x /bin/false ]; then
binfalse=/bin/false
else
- binfalse=true
+ binfalse=false
fi
shopt -s lastpipe
@@ -58,4 +71,3 @@ ${THIS_SH} ./lastpipe1.sub
echo lastpipe1.sub returns $?
${THIS_SH} ./lastpipe2.sub
-
diff --git a/tests/lastpipe2.sub b/tests/lastpipe2.sub
index 3bcc37d3..a4602863 100644
--- a/tests/lastpipe2.sub
+++ b/tests/lastpipe2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
shopt -s lastpipe
echo -e 'A\nB' | while read letter; do
echo -e '1\n2' | while read digit; do
diff --git a/tests/mapfile.tests b/tests/mapfile.tests
index ff8da32b..01f1f2e5 100644
--- a/tests/mapfile.tests
+++ b/tests/mapfile.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
declare -a A
mapfile A < mapfile.data
for (( i = 0 ; i < ${#A[@]} ; i++ )); do
diff --git a/tests/more-exp.right b/tests/more-exp.right
index 91a375cb..f5f37c92 100644
--- a/tests/more-exp.right
+++ b/tests/more-exp.right
@@ -108,7 +108,7 @@ argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
argv[6] = <f>
-./more-exp.tests: line 272: abc=def: command not found
+./more-exp.tests: line 285: abc=def: command not found
argv[1] = <a b c d e>
argv[1] = <a>
argv[2] = <b>
@@ -184,13 +184,13 @@ argv[1] = <1>
argv[1] = <5>
argv[1] = <5>
argv[1] = <0>
-./more-exp.tests: line 423: ${#:}: bad substitution
-./more-exp.tests: line 425: ${#/}: bad substitution
-./more-exp.tests: line 427: ${#%}: bad substitution
-./more-exp.tests: line 429: ${#=}: bad substitution
-./more-exp.tests: line 431: ${#+}: bad substitution
-./more-exp.tests: line 433: ${#1xyz}: bad substitution
-./more-exp.tests: line 436: #: %: syntax error: operand expected (error token is "%")
+./more-exp.tests: line 436: ${#:}: bad substitution
+./more-exp.tests: line 438: ${#/}: bad substitution
+./more-exp.tests: line 440: ${#%}: bad substitution
+./more-exp.tests: line 442: ${#=}: bad substitution
+./more-exp.tests: line 444: ${#+}: bad substitution
+./more-exp.tests: line 446: ${#1xyz}: bad substitution
+./more-exp.tests: line 449: #: %: syntax error: operand expected (error token is "%")
argv[1] = <0>
argv[1] = <a+b>
argv[1] = <+>
diff --git a/tests/more-exp.tests b/tests/more-exp.tests
index 10b3a47e..df12b998 100644
--- a/tests/more-exp.tests
+++ b/tests/more-exp.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
expect()
{
echo expect "$@"
diff --git a/tests/nameref.right b/tests/nameref.right
index 698002ec..296105c9 100644
--- a/tests/nameref.right
+++ b/tests/nameref.right
@@ -27,12 +27,12 @@ changevar: expect <three four five>
argv[1] = <three four five>
expect <three four five>
argv[1] = <three four five>
-./nameref.tests: line 93: foo: readonly variable
-./nameref.tests: line 94: foo: readonly variable
+./nameref.tests: line 106: foo: readonly variable
+./nameref.tests: line 107: foo: readonly variable
one
one
-./nameref.tests: line 106: foo: readonly variable
-./nameref.tests: line 103: foo: readonly variable
+./nameref.tests: line 119: foo: readonly variable
+./nameref.tests: line 116: foo: readonly variable
one
abxde
abxde
@@ -48,8 +48,8 @@ argv[1] = <unset>
expect <bar>
argv[1] = <bar>
expect <unset>
-./nameref3.sub: line 16: foo: invalid indirect expansion
-./nameref3.sub: line 21: unset: bar: cannot unset: readonly variable
+./nameref3.sub: line 29: foo: invalid indirect expansion
+./nameref3.sub: line 34: unset: bar: cannot unset: readonly variable
expect <two>
two
expect <two>
@@ -105,14 +105,14 @@ ref -> one, value: 1
ref -> two, value: 2
ref -> three, value: 3
final state: ref -> three, value: 3
-./nameref5.sub: line 43: unset: three: cannot unset: readonly variable
+./nameref5.sub: line 56: unset: three: cannot unset: readonly variable
ref -> one, value: 1
ref -> two, value: 2
ref -> three, value: 3
final state: ref -> three, value: 3
-./nameref6.sub: line 2: typeset: x: nameref variable self references not allowed
-./nameref6.sub: line 5: typeset: x[3]: reference variable cannot be an array
-./nameref6.sub: line 12: typeset: x: reference variable cannot be an array
+./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
the -- 1
42 -- 0
y -- 0
@@ -121,23 +121,23 @@ y -- 0
y -- 0
bar
unset
-./nameref8.sub: line 3: typeset: warning: v: circular name reference
-./nameref8.sub: line 3: warning: v: circular name reference
-./nameref8.sub: line 5: warning: v: circular name reference
+./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: circular name reference
inside
inside: two
outside:
-./nameref8.sub: line 29: typeset: warning: x: circular name reference
-./nameref8.sub: line 29: warning: x: circular name reference
-./nameref8.sub: line 31: warning: x: circular name reference
+./nameref8.sub: line 42: typeset: warning: x: circular name reference
+./nameref8.sub: line 42: warning: x: circular name reference
+./nameref8.sub: line 44: warning: x: circular name reference
foo
-./nameref8.sub: line 38: typeset: warning: v: circular name reference
-./nameref8.sub: line 38: warning: v: circular name reference
-./nameref8.sub: line 38: warning: v: circular name reference
+./nameref8.sub: line 51: typeset: warning: v: circular name reference
+./nameref8.sub: line 51: warning: v: circular name reference
+./nameref8.sub: line 51: warning: v: circular name reference
local
-./nameref8.sub: line 47: typeset: v: nameref variable self references not allowed
-./nameref8.sub: line 54: warning: x: circular name reference
-./nameref8.sub: line 55: warning: x: circular name reference
+./nameref8.sub: line 60: typeset: v: nameref variable self references not allowed
+./nameref8.sub: line 67: warning: x: circular name reference
+./nameref8.sub: line 68: warning: x: circular name reference
x =
idx2
idX2
@@ -157,107 +157,107 @@ comsub
comsub
4
declare -n foo="somevariable"
-./nameref10.sub: line 38: typeset: somevariable: not found
+./nameref10.sub: line 51: typeset: somevariable: not found
foo =
declare -n foo="somevariable"
declare -A somevariable=([jug]="brown" )
declare -n foo="somevariable"
declare -A somevariable=([jug]="brown" )
declare -n foo="somevariable"
-./nameref10.sub: line 49: typeset: somevariable: not found
-./nameref10.sub: line 51: typeset: foo: not found
-./nameref10.sub: line 51: typeset: somevariable: not found
+./nameref10.sub: line 62: typeset: somevariable: not found
+./nameref10.sub: line 64: typeset: foo: not found
+./nameref10.sub: line 64: typeset: somevariable: not found
declare -n foo="bar"
-./nameref10.sub: line 55: typeset: bar: not found
+./nameref10.sub: line 68: typeset: bar: not found
declare -n foo="bar"
-./nameref10.sub: line 57: typeset: bar: not found
+./nameref10.sub: line 70: typeset: bar: not found
declare -n foo="bar"
declare -i bar="8"
8
declare -n foo="bar"
-./nameref10.sub: line 64: typeset: bar: not found
-./nameref11.sub: line 1: declare: `/': invalid variable name for name reference
-./nameref11.sub: line 2: declare: `/': invalid variable name for name reference
-./nameref11.sub: line 3: `/': not a valid identifier
-./nameref11.sub: line 4: declare: `/': not a valid identifier
-./nameref11.sub: line 5: `/': not a valid identifier
+./nameref10.sub: line 77: typeset: bar: not found
+./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
+./nameref11.sub: line 17: declare: `/': not a valid identifier
+./nameref11.sub: line 18: `/': not a valid identifier
1) /
-#? ./nameref11.sub: line 6: `/': not a valid identifier
+#? ./nameref11.sub: line 19: `/': not a valid identifier
x
-./nameref11.sub: line 7: ((: `0': not a valid identifier
-./nameref11.sub: line 8: declare: `0': invalid variable name for name reference
-./nameref11.sub: line 9: declare: `/': invalid variable name for name reference
-./nameref11.sub: line 10: declare: `/': invalid variable name for name reference
+./nameref11.sub: line 20: ((: `0': not a valid identifier
+./nameref11.sub: line 21: declare: `0': invalid variable name for name reference
+./nameref11.sub: line 22: declare: `/': invalid variable name for name reference
+./nameref11.sub: line 23: declare: `/': invalid variable name for name reference
/
-./nameref11.sub: line 12: `/': not a valid identifier
-./nameref11.sub: line 13: exec: `10': not a valid identifier
-./nameref11.sub: line 13: r: cannot assign fd to variable
-./nameref11.sub: line 14: warning: r: removing nameref attribute
+./nameref11.sub: line 25: `/': not a valid identifier
+./nameref11.sub: line 26: exec: `10': not a valid identifier
+./nameref11.sub: line 26: r: cannot assign fd to variable
+./nameref11.sub: line 27: warning: r: removing nameref attribute
63
-./nameref11.sub: line 15: declare: RO: readonly variable
-./nameref11.sub: line 15: RO: readonly variable
-./nameref11.sub: line 16: declare: `/': invalid variable name for name reference
+./nameref11.sub: line 28: declare: RO: readonly variable
+./nameref11.sub: line 28: RO: readonly variable
+./nameref11.sub: line 29: declare: `/': invalid variable name for name reference
/
-./nameref11.sub: line 17: declare: `/': invalid variable name for name reference
+./nameref11.sub: line 30: declare: `/': invalid variable name for name reference
./nameref11.sub: illegal option -- h
-./nameref11.sub: line 18: getopts: `?': not a valid identifier
-./nameref11.sub: line 19: warning: r: removing nameref attribute
+./nameref11.sub: line 31: getopts: `?': not a valid identifier
+./nameref11.sub: line 32: warning: r: removing nameref attribute
declare -a r=()
-./nameref11.sub: line 20: declare: r: reference variable cannot be an array
-./nameref11.sub: line 21: printf: `/': not a valid identifier
-./nameref11.sub: line 23: `': not a valid identifier
-./nameref11.sub: line 24: declare: `': not a valid identifier
-./nameref11.sub: line 25: `': not a valid identifier
-./nameref11.sub: line 26: printf: `': not a valid identifier
-./nameref11.sub: line 27: declare: `': invalid variable name for name reference
+./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
declare -r ROVAR="42"
-./nameref11.sub: line 32: ROVAR: readonly variable
-./nameref11.sub: line 32: ROVAR: cannot unset: readonly variable
+./nameref11.sub: line 45: ROVAR: readonly variable
+./nameref11.sub: line 45: ROVAR: cannot unset: readonly variable
declare -r ROVAR="42"
./nameref11.sub
-./nameref11.sub: line 34: `@': not a valid identifier
+./nameref11.sub: line 47: `@': not a valid identifier
./nameref11.sub
declare -n ref="x"
-./nameref11.sub: line 39: RO: readonly variable
+./nameref11.sub: line 52: RO: readonly variable
declare -r RO_PID
-./nameref11.sub: line 39: RO: cannot unset: readonly variable
+./nameref11.sub: line 52: RO: cannot unset: readonly variable
declare -r RO="x"
-./nameref11.sub: line 39: declare: RO_PID: not found
-./nameref11.sub: line 41: RO2: readonly variable
+./nameref11.sub: line 52: declare: RO_PID: not found
+./nameref11.sub: line 54: RO2: readonly variable
declare -r RO2="a"
2
-./nameref11.sub: line 52: typeset: `2': invalid variable name for name reference
+./nameref11.sub: line 65: typeset: `2': invalid variable name for name reference
2
-./nameref11.sub: line 57: typeset: `2': invalid variable name for name reference
+./nameref11.sub: line 70: typeset: `2': invalid variable name for name reference
2
-./nameref11.sub: line 62: foo[2]: invalid indirect expansion
-./nameref11.sub: line 63: bar: invalid indirect expansion
-./nameref12.sub: line 6: declare: `/': invalid variable name for name reference
-./nameref12.sub: line 9: declare: `%': invalid variable name for name reference
-./nameref12.sub: line 13: `^': not a valid identifier
+./nameref11.sub: line 75: foo[2]: invalid indirect expansion
+./nameref11.sub: line 76: bar: invalid indirect expansion
+./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 -n r
declare -a foo
declare -a foo=([0]="7")
-./nameref12.sub: line 26: declare: `42': not a valid identifier
-./nameref12.sub: line 27: declare: x: not found
+./nameref12.sub: line 39: declare: `42': not a valid identifier
+./nameref12.sub: line 40: declare: x: not found
declare -nr RO="foo"
/
-./nameref12.sub: line 45: declare: `7*6': not a valid identifier
-./nameref12.sub: line 45: declare: foo: not found
-./nameref12.sub: line 47: `7*6': not a valid identifier
+./nameref12.sub: line 58: declare: `7*6': not a valid identifier
+./nameref12.sub: line 58: declare: foo: not found
+./nameref12.sub: line 60: `7*6': not a valid identifier
declare -n ref="var"
declare -n ref="var"
-./nameref12.sub: line 74: readonly: `var[0]': not a valid identifier
+./nameref12.sub: line 87: readonly: `var[0]': not a valid identifier
declare -- var="foo"
declare -r var2="foo"
declare -n ref="var"
declare -a var=([0]="foo")
-./nameref12.sub: line 91: `': not a valid identifier
+./nameref12.sub: line 104: `': not a valid identifier
declare -n ref
declare -- ref="global"
declare -a var=([0]="foo2")
-./nameref12.sub: line 100: declare: global: not found
+./nameref12.sub: line 113: declare: global: not found
declare -- a
declare -n r="a"
declare -- a
@@ -270,9 +270,9 @@ declare -n r="a"
0
declare -n r
declare -n r
-./nameref13.sub: line 88: typeset: `12345': invalid variable name for name reference
+./nameref13.sub: line 101: typeset: `12345': invalid variable name for name reference
declare -n foo
-./nameref13.sub: line 97: typeset: `12345': invalid variable name for name reference
+./nameref13.sub: line 110: typeset: `12345': invalid variable name for name reference
declare -n foo
declare -nx ref="var"
var
@@ -285,7 +285,7 @@ foo
foo
before
declare -n ref="var"
-./nameref14.sub: line 23: typeset: var: not found
+./nameref14.sub: line 36: typeset: var: not found
first
declare -n ref="var"
declare -x var="xxx"
@@ -294,105 +294,105 @@ declare -n ref="var"
declare -x var="5"
after
declare -n ref="var"
-./nameref14.sub: line 32: typeset: var: not found
+./nameref14.sub: line 45: typeset: var: not found
declare -n ref="var"
-./nameref15.sub: line 1: local: warning: a: circular name reference
-./nameref15.sub: line 1: warning: a: circular name reference
-./nameref15.sub: line 1: `a[0]': not a valid identifier
+./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 a=([0]="0")
-./nameref15.sub: line 1: local: warning: a: circular name reference
-./nameref15.sub: line 1: warning: a: circular name reference
-./nameref15.sub: line 1: warning: a: circular name reference
+./nameref15.sub: line 14: local: warning: a: circular name reference
+./nameref15.sub: line 14: warning: a: circular name reference
+./nameref15.sub: line 14: warning: a: circular name reference
declare -a a=([0]="X")
declare -a b=([0]="X")
-./nameref15.sub: line 1: local: warning: a: circular name reference
-./nameref15.sub: line 1: warning: a: circular name reference
-./nameref15.sub: line 1: `a[0]': not a valid identifier
+./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 b=([0]="0")
-./nameref15.sub: line 19: typeset: warning: ref: circular name reference
-./nameref15.sub: line 19: warning: ref: circular name reference
-./nameref15.sub: line 20: warning: ref: circular name reference
-./nameref15.sub: line 21: warning: ref: circular name reference
+./nameref15.sub: line 32: typeset: warning: ref: circular name reference
+./nameref15.sub: line 32: warning: ref: circular name reference
+./nameref15.sub: line 33: warning: ref: circular name reference
+./nameref15.sub: line 34: warning: ref: circular name reference
inside X
outside X
before: 7
-./nameref15.sub: line 32: typeset: warning: xxx: circular name reference
-./nameref15.sub: line 32: warning: xxx: circular name reference
-./nameref15.sub: line 33: warning: xxx: circular name reference
+./nameref15.sub: line 45: typeset: warning: xxx: circular name reference
+./nameref15.sub: line 45: warning: xxx: circular name reference
+./nameref15.sub: line 46: warning: xxx: circular name reference
declare -n xxx="xxx"
-./nameref15.sub: line 35: warning: xxx: circular name reference
+./nameref15.sub: line 48: warning: xxx: circular name reference
xxx_func: inside: xxx = foo
after: foo
-./nameref15.sub: line 46: typeset: ref: nameref variable self references not allowed
-./nameref15.sub: line 48: ref: nameref variable self references not allowed
+./nameref15.sub: line 59: typeset: ref: nameref variable self references not allowed
+./nameref15.sub: line 61: ref: nameref variable self references not allowed
declare -n ref="re"
declare -n ref="re"
declare -- re="4"
4
declare -n foo="var[@]"
declare -n ref="var[@]"
-./nameref15.sub: line 65: var[@]: bad array subscript
+./nameref15.sub: line 78: var[@]: bad array subscript
declare -n bar="var[@]"
-./nameref15.sub: line 70: var[@]: bad array subscript
+./nameref15.sub: line 83: var[@]: bad array subscript
declare -n a="b"
declare -n b="a[1]"
-./nameref15.sub: line 78: warning: a: removing nameref attribute
+./nameref15.sub: line 91: warning: a: removing nameref attribute
declare -a a=([1]="foo")
declare -n b="a[1]"
-./nameref15.sub: line 83: warning: a: removing nameref attribute
+./nameref15.sub: line 96: warning: a: removing nameref attribute
declare -a a=([1]="foo")
declare -n b="a[1]"
declare -n n="v"
declare -a v=([1]="1")
-./nameref15.sub: line 99: typeset: n: not found
+./nameref15.sub: line 112: typeset: n: not found
declare -a v=([0]="0" [1]="1")
declare -n n="v[1]"
declare -a v=([0]="0")
declare -n r1="y"
declare -n r2="x"
-./nameref16.sub: line 12: typeset: x: not found
-./nameref16.sub: line 12: typeset: y: not found
+./nameref16.sub: line 25: typeset: x: not found
+./nameref16.sub: line 25: typeset: y: not found
declare -n r1="y"
declare -n r2="x"
-./nameref16.sub: line 21: typeset: x: not found
-./nameref16.sub: line 21: typeset: y: not found
+./nameref16.sub: line 34: typeset: x: not found
+./nameref16.sub: line 34: typeset: y: not found
declare -n r1="y"
declare -n r2="x"
-./nameref16.sub: line 33: typeset: x: not found
-./nameref16.sub: line 33: typeset: y: not found
+./nameref16.sub: line 46: typeset: x: not found
+./nameref16.sub: line 46: typeset: y: not found
declare -n r1="y"
declare -n r2="x"
declare -- x="one"
declare -- y="two"
-./nameref17.sub: line 8: declare: bar: not found
-./nameref17.sub: line 9: unset: foo0: cannot unset: readonly variable
+./nameref17.sub: line 21: declare: bar: not found
+./nameref17.sub: line 22: unset: foo0: cannot unset: readonly variable
declare -nr foo0="bar"
declare -nr foo0="bar"
declare -- bar
-./nameref17.sub: line 14: declare: foo0: readonly variable
-./nameref17.sub: line 15: declare: foo0: readonly variable
+./nameref17.sub: line 27: declare: foo0: readonly variable
+./nameref17.sub: line 28: declare: foo0: readonly variable
declare -nr foo1
-./nameref17.sub: line 24: typeset: foo1: readonly variable
+./nameref17.sub: line 37: typeset: foo1: readonly variable
declare -nr foo1
declare -n foo2="bar"
declare -r bar
-./nameref17.sub: line 35: bar: readonly variable
-./nameref17.sub: line 36: typeset: bar: readonly variable
+./nameref17.sub: line 48: bar: readonly variable
+./nameref17.sub: line 49: typeset: bar: readonly variable
declare -n foo2="bar"
declare -r bar
declare -- bar3="three"
-./nameref17.sub: line 46: unset: foo3: cannot unset: readonly variable
-./nameref17.sub: line 49: declare: bar3: readonly variable
+./nameref17.sub: line 59: unset: foo3: cannot unset: readonly variable
+./nameref17.sub: line 62: declare: bar3: readonly variable
declare -nr foo3="bar3"
declare -r bar3="three"
-./nameref17.sub: line 51: declare: foo3: readonly variable
+./nameref17.sub: line 64: declare: foo3: readonly variable
declare -nr foo4="bar4"
declare -- bar4="four"
-./nameref17.sub: line 63: typeset: foo4: readonly variable
+./nameref17.sub: line 76: typeset: foo4: readonly variable
declare -nr foo4="bar4"
declare -nr foo4="bar4"
declare -- bar4="four"
-./nameref17.sub: line 79: typeset: foo4: readonly variable
+./nameref17.sub: line 92: typeset: foo4: readonly variable
declare -nr foo4="bar4"
declare -nr foo4="bar4"
declare -- bar4="four"
@@ -400,33 +400,33 @@ declare -nr foo5
declare -r foo5
declare -nr foo5
declare -r foo5
-./nameref18.sub: line 2: mapfile: `XXX[0]': not a valid identifier
-./nameref18.sub: line 3: declare: XXX[0]: not found
-./nameref18.sub: line 9: `XXX[0]': not a valid identifier
-./nameref18.sub: line 10: declare: XXX[0]: not found
+./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
+./nameref18.sub: line 23: declare: XXX[0]: not found
declare -n ref="XXX[0]"
declare -a XXX=([0]="4")
-./nameref18.sub: line 24: `XXX[0]': not a valid identifier
+./nameref18.sub: line 37: `XXX[0]': not a valid identifier
declare -n ref="XXX[0]"
-./nameref18.sub: line 25: declare: XXX[0]: not found
-./nameref18.sub: line 29: read: `XXX[0]': not a valid identifier
-./nameref18.sub: line 30: declare: XXX[0]: not found
-./nameref18.sub: line 35: `XXX[0]': not a valid identifier
-declare -n ref="XXX[0]"
-./nameref18.sub: line 38: `XXX[0]': not a valid identifier
./nameref18.sub: line 38: declare: XXX[0]: not found
+./nameref18.sub: line 42: read: `XXX[0]': not a valid identifier
+./nameref18.sub: line 43: declare: XXX[0]: not found
+./nameref18.sub: line 48: `XXX[0]': not a valid identifier
+declare -n ref="XXX[0]"
+./nameref18.sub: line 51: `XXX[0]': not a valid identifier
+./nameref18.sub: line 51: declare: XXX[0]: not found
declare -n ref="var[123]"
-./nameref18.sub: line 46: declare: var[123]: not found
+./nameref18.sub: line 59: declare: var[123]: not found
declare -a var=([123]="")
declare -n ref="var[123]"
-./nameref18.sub: line 50: declare: var[123]: not found
+./nameref18.sub: line 63: declare: var[123]: not found
declare -a var=([123]="")
declare -n ref="var[123]"
-./nameref18.sub: line 54: declare: var[123]: not found
+./nameref18.sub: line 67: declare: var[123]: not found
declare -a var=([123]="X")
declare -n foo="bar"
declare -- foo="bar"
-./nameref19.sub: line 9: declare: bar: not found
+./nameref19.sub: line 22: declare: bar: not found
declare -n foo="bar"
declare -- foo="bar"
declare -i bar="11"
@@ -448,27 +448,27 @@ declare -a var=([0]="X")
declare -n ref="var"
declare -a var=([0]="X")
declare -n ref="var"
-./nameref20.sub: line 23: declare: var: not found
+./nameref20.sub: line 36: declare: var: not found
outside:
declare -a foo=([0]="X")
declare -n ref="var"
declare -a var=([0]="X")
outside:
-./nameref20.sub: line 38: declare: ref: not found
-./nameref20.sub: line 38: declare: var: not found
+./nameref20.sub: line 51: declare: ref: not found
+./nameref20.sub: line 51: declare: var: not found
declare -n ref="var"
declare -- var="X"
outside:
-./nameref20.sub: line 45: declare: ref: not found
-./nameref20.sub: line 45: declare: var: not found
+./nameref20.sub: line 58: declare: ref: not found
+./nameref20.sub: line 58: declare: var: not found
declare -n ref="var"
declare -a var=([0]="Y")
declare -- ref="Y"
declare -- var="X"
-ref=Y
declare -- ref="Y"
-./nameref20.sub: line 61: declare: var: not found
-ref=Y
+declare -- ref="Y"
+./nameref20.sub: line 74: declare: var: not found
+declare -- ref="Y"
declare -n ref="var"
declare -A var=([2]="" )
declare -n ref="var"
diff --git a/tests/nameref.tests b/tests/nameref.tests
index f4af904c..3a6c5d98 100644
--- a/tests/nameref.tests
+++ b/tests/nameref.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# basic nameref tests
bar=one
flow=two
diff --git a/tests/nameref10.sub b/tests/nameref10.sub
index 2a1ba359..742755b3 100644
--- a/tests/nameref10.sub
+++ b/tests/nameref10.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# testing behavior of command substitution as one of expansions performed by
# array subscripting; should behave the same directly as when done through
# a nameref
diff --git a/tests/nameref11.sub b/tests/nameref11.sub
index 402e5015..ea14c0db 100644
--- a/tests/nameref11.sub
+++ b/tests/nameref11.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
r=/; declare -n r ; unset r
declare -n r=/ ; unset -n r
declare -n r; r=/ ; unset -n r
diff --git a/tests/nameref12.sub b/tests/nameref12.sub
index 24c33702..199b51c8 100644
--- a/tests/nameref12.sub
+++ b/tests/nameref12.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
declare -n r
declare -n r
unset -n r
diff --git a/tests/nameref13.sub b/tests/nameref13.sub
index 556fbdb7..5c56428b 100644
--- a/tests/nameref13.sub
+++ b/tests/nameref13.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
declare -nt r=a
f()
diff --git a/tests/nameref14.sub b/tests/nameref14.sub
index 7880b007..a14c440c 100644
--- a/tests/nameref14.sub
+++ b/tests/nameref14.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# exporting namerefs and putting namerefs in temp env post bash-4.3
typeset -nx ref=var;
diff --git a/tests/nameref15.sub b/tests/nameref15.sub
index 9fbacd4f..cce8fbd9 100644
--- a/tests/nameref15.sub
+++ b/tests/nameref15.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
f() { local -n a=$1; a=X; }
a=(0); f 'a[0]'
diff --git a/tests/nameref16.sub b/tests/nameref16.sub
index 75c7ba11..d07a3a02 100644
--- a/tests/nameref16.sub
+++ b/tests/nameref16.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# post-bash-4.3 changes for more ksh93 compatibility when following nameref
# chains and using typeset/declare -n to operate on nameref variables rather
# than the variables they reference
diff --git a/tests/nameref17.sub b/tests/nameref17.sub
index 0cd5a42d..b8c3cc73 100644
--- a/tests/nameref17.sub
+++ b/tests/nameref17.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test behavior of readonly namerefs and namerefs referencing readonly variables
# readonly nameref variable referencing read-write global variable
diff --git a/tests/nameref18.sub b/tests/nameref18.sub
index 1b022959..a29fe379 100644
--- a/tests/nameref18.sub
+++ b/tests/nameref18.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
declare -n ref=XXX[0]
mapfile ref <<< $'1\n2'
declare -p XXX[0]
diff --git a/tests/nameref19.sub b/tests/nameref19.sub
index d46c003f..b00f68e5 100644
--- a/tests/nameref19.sub
+++ b/tests/nameref19.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# can we unset the nameref attribute on variables with values that reference
# unset variables?
diff --git a/tests/nameref20.sub b/tests/nameref20.sub
index 1e6faec9..715bc4dc 100644
--- a/tests/nameref20.sub
+++ b/tests/nameref20.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# a collection of cases in bug reports after bash-5.0-alpha was released
declare -n r=v[0]
diff --git a/tests/nameref21.sub b/tests/nameref21.sub
index a555a084..08d8f561 100644
--- a/tests/nameref21.sub
+++ b/tests/nameref21.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# issues with local variables and local namerefs post-bash-4.4
f()
diff --git a/tests/nameref3.sub b/tests/nameref3.sub
index 57902917..67cb0982 100644
--- a/tests/nameref3.sub
+++ b/tests/nameref3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# nameref requires changes to unset
bar=one
typeset -n foo=bar
diff --git a/tests/nameref4.sub b/tests/nameref4.sub
index 4dd86b2f..6367d565 100644
--- a/tests/nameref4.sub
+++ b/tests/nameref4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test suite cribbed from ksh93 nameref tests
typeset -i errors=0
ckval()
diff --git a/tests/nameref5.sub b/tests/nameref5.sub
index 2c67a948..6855e992 100644
--- a/tests/nameref5.sub
+++ b/tests/nameref5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# nameref variables as for loop index variables are special
v1=1
v2=2
diff --git a/tests/nameref6.sub b/tests/nameref6.sub
index cf70d412..8497967f 100644
--- a/tests/nameref6.sub
+++ b/tests/nameref6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# these should be errors
typeset -n x=x
#echo $x -- $?
diff --git a/tests/nameref7.sub b/tests/nameref7.sub
index 19bdc989..5e67ac04 100644
--- a/tests/nameref7.sub
+++ b/tests/nameref7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
fn ()
{
declare -n var=foo; var=bar
diff --git a/tests/nameref8.sub b/tests/nameref8.sub
index 23808682..465463bf 100644
--- a/tests/nameref8.sub
+++ b/tests/nameref8.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
function f1
{
typeset -n v=$1
diff --git a/tests/new-exp.right b/tests/new-exp.right
index c0f78fbb..752bba5c 100644
--- a/tests/new-exp.right
+++ b/tests/new-exp.right
@@ -3,7 +3,7 @@ argv[1] = <foo>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
-./new-exp.tests: line 28: HOME: }: syntax error: operand expected (error token is "}")
+./new-exp.tests: line 41: HOME: }: syntax error: operand expected (error token is "}")
unset
argv[1] = </usr/homes/chet>
argv[1] = </usr/homes/chet>
@@ -66,8 +66,8 @@ argv[4] = <d>
argv[1] = <a>
argv[2] = <b c>
argv[3] = <d>
-./new-exp.tests: line 184: ABX: unbound variable
-./new-exp.tests: line 188: $6: cannot assign in this way
+./new-exp.tests: line 197: ABX: unbound variable
+./new-exp.tests: line 201: $6: cannot assign in this way
argv[1] = <xxcde>
argv[1] = <axxde>
argv[1] = <abxyz>
@@ -170,13 +170,13 @@ This-string-has-multiple-lines.
this is a test of proc subst
this is test 2
a
-./new-exp2.sub: line 42: /tmp/redir-notthere: No such file or directory
+./new-exp2.sub: line 55: /tmp/redir-notthere: No such file or directory
1
-./new-exp2.sub: line 49: 1111111111111111111111: command not found
+./new-exp2.sub: line 62: 1111111111111111111111: command not found
argv[1] = <6>
-./new-exp.tests: line 289: ${#:}: bad substitution
+./new-exp.tests: line 302: ${#:}: bad substitution
argv[1] = <'>
argv[1] = <">
argv[1] = <"hello">
@@ -411,13 +411,13 @@ argv[6] = <w>
argv[7] = <x>
argv[8] = <y>
argv[9] = <z>
-./new-exp.tests: line 507: $9: unbound variable
-./new-exp.tests: line 508: 9: unbound variable
-./new-exp.tests: line 509: UNSET: unbound variable
-./new-exp.tests: line 510: UNSET: unbound variable
-./new-exp.tests: line 511: UNSET: unbound variable
-./new-exp.tests: line 512: UNSET: unbound variable
-./new-exp.tests: line 513: UNSET: unbound variable
+./new-exp.tests: line 520: $9: unbound variable
+./new-exp.tests: line 521: 9: 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
+./new-exp.tests: line 525: UNSET: unbound variable
+./new-exp.tests: line 526: UNSET: unbound variable
argv[1] = <5>
argv[1] = <#>
argv[1] = <#>
@@ -453,9 +453,9 @@ argv[3] = <_QUEST>
argv[4] = <_QUILL>
argv[5] = <_QUOTA>
argv[6] = <_QUOTE>
-./new-exp3.sub: line 23: ${!_Q* }: bad substitution
-./new-exp3.sub: line 28: ${!1*}: bad substitution
-./new-exp3.sub: line 30: ${!@*}: bad substitution
+./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---
@@ -464,7 +464,7 @@ Case05---3---A:B:C---
Case06---1---A B C::---
Case07---3---A:B:C---
Case08---3---A:B:C---
-./new-exp.tests: line 533: ${$(($#-1))}: bad substitution
+./new-exp.tests: line 546: ${$(($#-1))}: bad substitution
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
@@ -481,7 +481,8 @@ argv[1] = <a>
argv[1] = <a>
argv[2] = <b>
argv[1] = <>
-./new-exp.tests: line 552: $(($# - 2)): substring expression < 0
+./new-exp.tests: line 565: $(($# - 2)): substring expression < 0
+./new-exp.tests: line 567: -2: substring expression < 0
argv[1] = <bin>
argv[2] = <bin>
argv[3] = <ucb>
@@ -616,7 +617,7 @@ c Sub = 0 2 4 8
<>
<>
<'ab '\''cd'\'' ef'>
-./new-exp10.sub: line 11: ${x@C}: bad substitution
+./new-exp10.sub: line 24: ${x@C}: bad substitution
<'ab'> <'cd ef'> <''> <'gh'>
<'ab' 'cd ef' '' 'gh'>
<'ab'> <'cd> <ef'> <''> <'gh'>
@@ -624,7 +625,7 @@ c Sub = 0 2 4 8
<'ab cd'>
<'4'> <'ab cd'>
<>
-argv[1] = <host(2)[5.0]$ >
+argv[1] = <host(2)[5.1]$ >
<
>
<' \t\n'>
@@ -635,7 +636,7 @@ declare -r x='ab '\''cd'\'' ef'
set -- 'ab' 'cd ef' '' 'gh'
declare -a A=([0]="ab" [1]="cd ef" [2]="" [3]="gh")
declare -a B=()
-declare -A A=([two]="b c" [three]="" [four]="de" [one]="1" )
+declare -A A=([four]="de" [two]="b c" [three]="" [one]="1" )
r
a
A
@@ -667,6 +668,58 @@ prependå
Ã¥
ḅć
ḅć
+HELLO;1 foo;2 foo;
+PASS;1 foo;2 foo;
+after: PASS
+'zzz'
+'zzz'
+declare -rl VAR1
+declare -rl VAR1
+declare -rl VAR1
+declare -rl VAR1
+rl
+rl
+rl
+rl
+declare -arl VAR3
+declare -arl VAR3
+declare -arl VAR3
+declare -arl VAR3
+arl
+arl
+arl
+arl
+one
+one
+'aaa'
+'aaa' 'bbb'
+./new-exp13.sub: line 56: aaa bbb: invalid variable name
+aaa bbb
+0 1
+'aaa'
+'aaa' 'bbb'
+'aaa' 'bbb'
+'aaa' 'bbb'
+a bbb
+aaa bb
+'string'
+'value with spaces'
+'a b' 'c d' 'e f'
+'a b' 'c d' 'e f'
+0 "zero" 1 "one" 2 "two" 3 "three"
+0 "zero z" 1 "one o" 2 "two t" 3 "three t"
+declare -a foo=()
+ai
+declare -ai foo
+bash: line 1: foo: unbound variable
+ai
+declare -ai foo
+bash: line 1: !bar: unbound variable
+a
+a
+a
+a
argv[1] = </>
argv[1] = </>
-./new-exp.tests: line 615: ABXD: parameter unset
+
+./new-exp.tests: line 1: ABXD: parameter unset
diff --git a/tests/new-exp.tests b/tests/new-exp.tests
index 557d6b44..079426cb 100644
--- a/tests/new-exp.tests
+++ b/tests/new-exp.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
if (( $UID == 0 )); then
echo "new-exp.tests: the test suite should not be run as root" >&2
fi
@@ -550,6 +563,8 @@ recho "${*:1:0}"
# this is an error -- negative expression
set a
recho ${@:1:$(($# - 2))}
+set a b c d e
+recho ${@: -3:-2}
XPATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:.:/sbin:/usr/sbin
set $( IFS=: ; echo $XPATH )
@@ -604,12 +619,32 @@ ${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
+
# problems with stray CTLNUL in bash-4.0-alpha
unset a
a=/a
recho "/${a%/*}"
recho "/${a///a/}"
-# this must be last!
+patfunc()
+{
+ echo ${1##*"${1##*}"}
+}
+patfunc foo
+
+# caused core dumps because of bad bracket expression parsing in bash-5.0
+eval : $'${x/#[0\xef\xbf\xbd\\Z[:]]}'
+
expect $0: 'ABXD: parameter unset'
-recho ${ABXD:?"parameter unset"}
+${THIS_SH} -c 'recho ${ABXD:?"parameter unset"}' $0
diff --git a/tests/new-exp1.sub b/tests/new-exp1.sub
index 2b621fca..d29b93c7 100644
--- a/tests/new-exp1.sub
+++ b/tests/new-exp1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
FN=${TMPDIR}/bashtest-$$
expect()
{
diff --git a/tests/new-exp10.sub b/tests/new-exp10.sub
index 9e89a701..bf9ebe7a 100644
--- a/tests/new-exp10.sub
+++ b/tests/new-exp10.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# new framework for parameter transformations, post bash-4.3
printf "<%s>" "${x@Q}" ; echo
diff --git a/tests/new-exp11.sub b/tests/new-exp11.sub
index da6b4e1f..6a9edd59 100644
--- a/tests/new-exp11.sub
+++ b/tests/new-exp11.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# pattern matching and replacement operators with multibyte characters
LANG=en_US.UTF-8
diff --git a/tests/new-exp12.sub b/tests/new-exp12.sub
new file mode 100644
index 00000000..1fbd5d63
--- /dev/null
+++ b/tests/new-exp12.sub
@@ -0,0 +1,40 @@
+# 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/>.
+#
+#
+# make sure indirect expansion for arrays uses the closest-scope instance
+# of the resulting variable name
+
+array_1=("PASS")
+array_2=("1 foo" "2 foo")
+
+unsafe_fn ()
+{
+ local array_1=('HELLO')
+ local a=("${!1}") b=("${!2}")
+ printf '%s;' "${a[@]}" "${b[@]}"
+ printf '\n'
+}
+
+safe_fn ()
+{
+ local a=("${!1}") b=("${!2}")
+ local array_1=('FAIL')
+ printf '%s;' "${a[@]}" "${b[@]}"
+ printf '\n'
+}
+
+unsafe_fn 'array_1[@]' 'array_2[@]'
+safe_fn 'array_1[@]' 'array_2[@]'
+
+echo after: ${array_1[@]}
diff --git a/tests/new-exp13.sub b/tests/new-exp13.sub
new file mode 100644
index 00000000..7e8ed32c
--- /dev/null
+++ b/tests/new-exp13.sub
@@ -0,0 +1,72 @@
+# 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/>.
+#
+
+declare -lr VAR1
+declare -lr VAR2=zzz
+declare -alr VAR3
+
+var=VAR2
+
+echo ${!var@Q}
+echo ${VAR2@Q}
+
+echo ${VAR1@A}
+echo ${VAR1[@]@A}
+echo "${VAR1@A}"
+echo "${VAR1[@]@A}"
+
+echo "${VAR1[@]@a}"
+echo ${VAR1[@]@a}
+echo "${VAR1@a}"
+echo ${VAR1@a}
+
+echo ${VAR3@A}
+echo ${VAR3[@]@A}
+echo "${VAR3@A}"
+echo "${VAR3[@]@A}"
+
+echo "${VAR3[@]@a}"
+echo ${VAR3[@]@a}
+echo "${VAR3@a}"
+echo ${VAR3@a}
+
+var=one
+
+echo ${var}
+echo ${var[@]}
+
+VAR4=(aaa bbb)
+
+varname=VAR4
+
+echo ${!varname[@]@Q}
+
+echo ${VAR4[@]@Q}
+echo ${!VAR4[@]@Q}
+
+echo ${VAR4[@]}
+echo ${!VAR4[@]}
+
+VAR5=(aaa bbb)
+varname="VAR5[@]"
+
+echo "${VAR5@Q}"
+echo "${VAR5[@]@Q}"
+
+echo "${!varname@Q}"
+echo "${!varname[@]@Q}"
+
+# caused core dumps through bash-5.0
+echo "${!varname##aa}"
+echo "${!varname[@]%b}"
diff --git a/tests/new-exp14.sub b/tests/new-exp14.sub
new file mode 100644
index 00000000..b8bda8de
--- /dev/null
+++ b/tests/new-exp14.sub
@@ -0,0 +1,19 @@
+# test the other uses of the 'K' tranform operator
+# the associative array tests are performed separately, since that was the
+# original motivation for this feature
+foo=string
+bar='value with spaces'
+
+set -- 'a b' 'c d' 'e f'
+
+echo ${foo@K}
+echo ${bar@K}
+
+echo ${@@K}
+echo "${@@K}"
+
+foo=( zero one two three )
+echo ${foo[@]@K}
+
+foo=( 'zero z' 'one o' 'two t' 'three t' )
+echo ${foo[@]@K}
diff --git a/tests/new-exp15.sub b/tests/new-exp15.sub
new file mode 100644
index 00000000..f8b9ed84
--- /dev/null
+++ b/tests/new-exp15.sub
@@ -0,0 +1,29 @@
+# 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/>.
+#
+
+: ${THIS_SH:=./bash}
+
+${THIS_SH} -c 'declare -a foo=() ; declare -p foo' bash
+
+${THIS_SH} -c 'declare -ia foo=() ; echo ${foo@a} ; echo ${foo@A}' bash
+${THIS_SH} -uc 'declare -ia foo=() ; echo ${foo@a} ; echo ${foo@A}' bash
+
+${THIS_SH} -c 'declare -ia foo=() ; bar=foo; echo ${!bar@a} ; echo ${!bar@A}' bash
+${THIS_SH} -uc 'declare -ia foo=() ; bar=foo; echo ${!bar@a} ; echo ${!bar@A}' bash
+
+${THIS_SH} -c 'declare -a foo=( [1]=one ) ; echo ${foo@a}' bash
+${THIS_SH} -uc 'declare -a foo=( [1]=one ) ; echo ${foo@a}' bash
+
+${THIS_SH} -c 'declare -a foo=( [1]=one ) ; bar=foo; echo ${!bar@a}' bash
+${THIS_SH} -uc 'declare -a foo=( [1]=one ) ; bar=foo; echo ${!bar@a}' bash
diff --git a/tests/new-exp2.sub b/tests/new-exp2.sub
index ea52b3ce..8dfe788f 100644
--- a/tests/new-exp2.sub
+++ b/tests/new-exp2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
export LC_ALL=C
export LANG=C
@@ -37,7 +50,7 @@ if [[ $LINES2 -gt 0 ]]; then
fi
set +o posix
-# now see what happens when we try it with a non-existant file
+# now see what happens when we try it with a non-existent file
rm -f /tmp/redir-notthere
LINES3=$(< /tmp/redir-notthere)
echo $?
diff --git a/tests/new-exp3.sub b/tests/new-exp3.sub
index 2a766ebd..a0c6586d 100644
--- a/tests/new-exp3.sub
+++ b/tests/new-exp3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
:
# Set up some dummy variables beginning with _Q
_QUANTITY=
diff --git a/tests/new-exp4.sub b/tests/new-exp4.sub
index 45439a06..e491f5cf 100644
--- a/tests/new-exp4.sub
+++ b/tests/new-exp4.sub
@@ -1,4 +1,16 @@
-#!/bin/bash
+# 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/>.
+#
arrayA=("A" "B" "C")
diff --git a/tests/new-exp5.sub b/tests/new-exp5.sub
index 0ee86e98..cb203a70 100644
--- a/tests/new-exp5.sub
+++ b/tests/new-exp5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
x=(one two)
echo ${x[@]:1}
echo ${x[@]:0:1}
diff --git a/tests/new-exp6.sub b/tests/new-exp6.sub
index 532ec1af..83b041ac 100644
--- a/tests/new-exp6.sub
+++ b/tests/new-exp6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# quoted null problems in versions of bash prior to 3.2
str='12'
diff --git a/tests/new-exp8.sub b/tests/new-exp8.sub
index e047abce..9effec54 100644
--- a/tests/new-exp8.sub
+++ b/tests/new-exp8.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
pat1='str'
pat2='[^;]'
pat3='[[:alnum:]_]'
diff --git a/tests/new-exp9.sub b/tests/new-exp9.sub
index c9d133c8..799f192d 100644
--- a/tests/new-exp9.sub
+++ b/tests/new-exp9.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
indirarray()
{
local intermediary
diff --git a/tests/nquote.tests b/tests/nquote.tests
index 80d3cb46..20d6415d 100644
--- a/tests/nquote.tests
+++ b/tests/nquote.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
expect()
{
echo expect "$@"
diff --git a/tests/nquote1.tests b/tests/nquote1.tests
index f47ab54e..679976c6 100644
--- a/tests/nquote1.tests
+++ b/tests/nquote1.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
a=$'a\001b'
set $a
diff --git a/tests/nquote2.sub b/tests/nquote2.sub
index d3325f17..bfe2b190 100644
--- a/tests/nquote2.sub
+++ b/tests/nquote2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
t() {
printf '%s | %s\n' "$1" "$2"
}
diff --git a/tests/nquote2.tests b/tests/nquote2.tests
index c07bd9b8..e3af99af 100644
--- a/tests/nquote2.tests
+++ b/tests/nquote2.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
a=$'a\001b'
e=$'uv\001\001wx'
diff --git a/tests/nquote3.tests b/tests/nquote3.tests
index a83ff56d..44b51c40 100644
--- a/tests/nquote3.tests
+++ b/tests/nquote3.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
a=$'a\001b'
set $a
diff --git a/tests/nquote4.tests b/tests/nquote4.tests
index ed734677..5c67705b 100644
--- a/tests/nquote4.tests
+++ b/tests/nquote4.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
recho $'ab\x{}cd'
recho $'ab\x{41}cd'
recho $'ab\x41cd'
diff --git a/tests/nquote5.tests b/tests/nquote5.tests
index 85a2ff63..ca0308d7 100644
--- a/tests/nquote5.tests
+++ b/tests/nquote5.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
a=$'ab\001cd\001ef'
IFS=$'\001'
diff --git a/tests/parser.right b/tests/parser.right
index cecbb222..3a01004f 100644
--- a/tests/parser.right
+++ b/tests/parser.right
@@ -1,16 +1,16 @@
AAA
-bash5: `invalid-name': not a valid identifier
+bash5: line 1: `invalid-name': not a valid identifier
in
in
in
in
-bash5: -c: line 0: syntax error near unexpected token `)'
-bash5: -c: line 0: `case x in esac) echo done; esac'
+bash5: -c: line 1: syntax error near unexpected token `)'
+bash5: -c: line 1: `case x in esac) echo done; esac'
in
-bash5: -c: line 0: syntax error near unexpected token `do'
-bash5: -c: line 0: `case in do do) echo in; esac'
-bash5: -c: line 0: syntax error near unexpected token `('
-bash5: -c: line 0: `for()'
+bash5: -c: line 1: syntax error near unexpected token `do'
+bash5: -c: line 1: `case in do do) echo in; esac'
+bash5: -c: line 1: syntax error near unexpected token `('
+bash5: -c: line 1: `for()'
in
done
ok 1
diff --git a/tests/posix2.right b/tests/posix2.right
index b1585a2e..40aea039 100644
--- a/tests/posix2.right
+++ b/tests/posix2.right
@@ -1,6 +1,6 @@
Testing for POSIX.2 conformance
-./posix2.tests: eval: line 182: syntax error near unexpected token `esac'
-./posix2.tests: eval: line 182: `case esac in (esac) ;; *) echo "case esac test 3" ;; esac'
-./posix2.tests: eval: line 184: syntax error near unexpected token `)'
-./posix2.tests: eval: line 184: `case esac in esac) ;; *) echo "case esac test 4";; esac'
+./posix2.tests: eval: line 195: syntax error near unexpected token `esac'
+./posix2.tests: eval: line 195: `case esac in (esac) ;; *) echo "case esac test 3" ;; esac'
+./posix2.tests: eval: line 197: syntax error near unexpected token `)'
+./posix2.tests: eval: line 197: `case esac in esac) ;; *) echo "case esac test 4";; esac'
All tests passed
diff --git a/tests/posix2.tests b/tests/posix2.tests
index ecf6a6fa..9b6c0932 100644
--- a/tests/posix2.tests
+++ b/tests/posix2.tests
@@ -1,4 +1,17 @@
-#! /bin/sh
+# 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/>.
+#
+
# posix-2.sh - Simple identification tests for POSIX.2 features
# commonly missing or incorrectly implemented.
# Time-stamp: <96/04/10 16:43:48 gildea>
diff --git a/tests/posix2syntax.sub b/tests/posix2syntax.sub
index e7dda58f..39af9a55 100644
--- a/tests/posix2syntax.sub
+++ b/tests/posix2syntax.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${THIS_SH:=./bash}
bashname=bash${BASH_VERSION%%.*}
diff --git a/tests/posixexp.right b/tests/posixexp.right
index 53a08e3b..e6bdbf4b 100644
--- a/tests/posixexp.right
+++ b/tests/posixexp.right
@@ -279,5 +279,10 @@ argv[2] = <b>
OK
OK
5: $'not\ttoo\nbad'
-./posixexp.tests: line 83: unexpected EOF while looking for matching `}'
-./posixexp.tests: line 84: syntax error: unexpected end of file
+"A"
+A
+argv[1] = <"A">
+argv[1] = <A>
+argv[1] = <A>
+./posixexp.tests: line 97: unexpected EOF while looking for matching `}'
+./posixexp.tests: line 98: syntax error: unexpected end of file
diff --git a/tests/posixexp.tests b/tests/posixexp.tests
index 3368711f..d8f66441 100644
--- a/tests/posixexp.tests
+++ b/tests/posixexp.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
unset a
printf "%s\n" ${a:=a\ b}
echo "$a"
@@ -77,6 +90,7 @@ ${THIS_SH} ./posixexp4.sub
${THIS_SH} ./posixexp5.sub
${THIS_SH} ./posixexp6.sub
${THIS_SH} ./posixexp7.sub
+${THIS_SH} ./posixexp8.sub
# this will be an error
foo=bar
diff --git a/tests/posixexp1.sub b/tests/posixexp1.sub
index 91718e3d..c0d6861a 100644
--- a/tests/posixexp1.sub
+++ b/tests/posixexp1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# $FreeBSD: src/tools/regression/bin/sh/expansion/set-u1.0,v 1.2 2010/10/12 18:20:38 obrien Exp $
${THIS_SH} -uc 'unset foo; echo ${foo}' 2>/dev/null && exit 1
diff --git a/tests/posixexp2.sub b/tests/posixexp2.sub
index 397769da..5c46192c 100644
--- a/tests/posixexp2.sub
+++ b/tests/posixexp2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
x=a\ b
[ "$x" = "${x?}" ] || exit 1
diff --git a/tests/posixexp2.tests b/tests/posixexp2.tests
index 2bec58e0..5f2392b5 100644
--- a/tests/posixexp2.tests
+++ b/tests/posixexp2.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# From mksh
set -o posix ; shopt -u xpg_echo
diff --git a/tests/posixexp3.sub b/tests/posixexp3.sub
index c40afa94..343adfe3 100644
--- a/tests/posixexp3.sub
+++ b/tests/posixexp3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- 1 2
unset var
diff --git a/tests/posixexp4.sub b/tests/posixexp4.sub
index 22bfeca8..9d48b2f6 100644
--- a/tests/posixexp4.sub
+++ b/tests/posixexp4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -- ' abc' 'def ghi' 'jkl '
echo normal IFS
diff --git a/tests/posixexp5.sub b/tests/posixexp5.sub
index e477bbb1..b0e1c039 100644
--- a/tests/posixexp5.sub
+++ b/tests/posixexp5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test suite contribution from Martijn Dekker
defaultIFS=$IFS
diff --git a/tests/posixexp6.sub b/tests/posixexp6.sub
index ed38d535..b89b87f9 100644
--- a/tests/posixexp6.sub
+++ b/tests/posixexp6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
var=$'\01\02\03\177'
bar=${unset:-$var}
diff --git a/tests/posixexp8.sub b/tests/posixexp8.sub
new file mode 100644
index 00000000..383851c4
--- /dev/null
+++ b/tests/posixexp8.sub
@@ -0,0 +1,11 @@
+P=A
+
+cat << EOF
+${P+\"$P\"}
+${P+"$P"}
+EOF
+
+recho "${P+\"$P\"}"
+
+recho "${P+"$P"}"
+recho ${P+"$P"}
diff --git a/tests/posixpat.tests b/tests/posixpat.tests
index 65c557a3..5a7bafd7 100644
--- a/tests/posixpat.tests
+++ b/tests/posixpat.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# A test suite for the POSIX.2 (BRE) pattern matching code
LC_ALL=C
LANG=C
diff --git a/tests/posixpipe.tests b/tests/posixpipe.tests
index a2f047af..fa8febed 100644
--- a/tests/posixpipe.tests
+++ b/tests/posixpipe.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# Test timed and negated pipelines in bash-4.2 and later
export TIMEFORMAT=$'real %2R\nuser %2U\nsys %2S'
diff --git a/tests/precedence.tests b/tests/precedence.tests
new file mode 100755
index 00000000..111bd231
--- /dev/null
+++ b/tests/precedence.tests
@@ -0,0 +1,90 @@
+# @(#)precedence_test 1.0 91/07/24 Maarten Litmaath
+
+# 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 of relative precedences for `&&' and `||' operators
+
+echo "\`Say' echos its argument. Its return value is of no interest."
+case `echo -n` in
+ '') Say () { echo -n "$*" ; } ;;
+ *) Say () { echo "$*\c" ; } ;;
+esac
+
+echo "\`Truth' echos its argument and returns a TRUE result."
+Truth () {
+ Say $1;
+ return 0;
+}
+
+echo "\`False' echos its argument and returns a FALSE result."
+False () {
+ Say $1;
+ return 1;
+}
+
+echo ""
+
+cmd1='$open $test1 && $test2 $close || $test3'
+cmd2='$test1 || $open $test2 && $test3 $close'
+
+grouping_sh=
+grouping_C='( )'
+
+test3='Say 3'
+
+for i in 1 2
+do
+ eval proto=\$cmd$i
+
+ for test1 in 'Truth 1' 'False 1'
+ do
+ for test2 in 'Truth 2' 'False 2'
+ do
+ for precedence in sh C
+ do
+ eval set x \$grouping_$precedence
+ shift
+ open=${1-' '}
+ close=${2-' '}
+ eval cmd=\""$proto"\"
+ Say "$cmd output="
+ output=`eval "$cmd"`
+ Say "$output"
+ read correct || { echo 'Input fubar. Abort.' >&2; exit 1; }
+ test "X$output" = "X$correct" || echo " correct=$correct"
+ echo ''
+ done
+
+ echo ''
+ done
+ done
+done << EOF
+12
+12
+123
+123
+13
+13
+13
+13
+13
+1
+13
+1
+123
+123
+12
+12
+EOF
diff --git a/tests/printf.right b/tests/printf.right
index 593f084b..b032dcbf 100644
--- a/tests/printf.right
+++ b/tests/printf.right
@@ -30,7 +30,7 @@ A7
--\"abcd\"--
--\'abcd\'--
--a\x--
-./printf.tests: line 82: printf: missing hex digit for \x
+./printf.tests: line 95: printf: missing hex digit for \x
--\x--
----
----
@@ -91,12 +91,12 @@ A7
26
26
26
-./printf.tests: line 206: printf: `%10': missing format character
-./printf.tests: line 207: printf: `M': invalid format character
-ab./printf.tests: line 210: printf: `y': invalid format character
-./printf.tests: line 213: printf: GNU: invalid number
+./printf.tests: line 219: printf: `%10': missing format character
+./printf.tests: line 220: printf: `M': invalid format character
+ab./printf.tests: line 223: printf: `y': invalid format character
+./printf.tests: line 226: printf: GNU: invalid number
0
-./printf.tests: line 214: printf: GNU: invalid number
+./printf.tests: line 227: printf: GNU: invalid number
0
-
(foo )(bar )
@@ -174,7 +174,7 @@ A7
--\"abcd\"--
--\'abcd\'--
--a\x--
-./printf1.sub: line 94: printf: missing hex digit for \x
+./printf1.sub: line 107: printf: missing hex digit for \x
--\x--
----
----
@@ -235,12 +235,12 @@ A7
26
26
26
-./printf1.sub: line 280: printf: `%10': missing format character
-./printf1.sub: line 281: printf: `M': invalid format character
-./printf1.sub: line 284: printf: `y': invalid format character
-./printf1.sub: line 287: printf: GNU: invalid number
+./printf1.sub: line 293: printf: `%10': missing format character
+./printf1.sub: line 294: printf: `M': invalid format character
+./printf1.sub: line 297: printf: `y': invalid format character
+./printf1.sub: line 300: printf: GNU: invalid number
0
-./printf1.sub: line 289: printf: GNU: invalid number
+./printf1.sub: line 302: printf: GNU: invalid number
0
-
(foo )(bar )
@@ -252,7 +252,7 @@ A7
^Ge
"?
16:09:15
-./printf3.sub: line 14: printf: warning: `Z': invalid time format specification
+./printf3.sub: line 27: printf: warning: `Z': invalid time format specification
%(abde)Z
30-May-2010 16:09:15
05/30/10 15:09:15
diff --git a/tests/printf.tests b/tests/printf.tests
index 9dbac6f0..df37e47e 100644
--- a/tests/printf.tests
+++ b/tests/printf.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
LC_ALL=C
LC_NUMERIC=C
diff --git a/tests/printf1.sub b/tests/printf1.sub
index 52612d5c..e4fb54b8 100644
--- a/tests/printf1.sub
+++ b/tests/printf1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
LC_ALL=C
LC_NUMERIC=C
diff --git a/tests/printf3.sub b/tests/printf3.sub
index d45e101c..4c54aa12 100644
--- a/tests/printf3.sub
+++ b/tests/printf3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
LC_ALL=C
LANG=C
diff --git a/tests/printf4.sub b/tests/printf4.sub
index 2ffd9979..ed4c5383 100644
--- a/tests/printf4.sub
+++ b/tests/printf4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# Problems with padding, field widths, and `+' through bash-4.2
printf "x%10.0fx\n" 123
diff --git a/tests/procsub.right b/tests/procsub.right
index cf1dbb10..c6471c51 100644
--- a/tests/procsub.right
+++ b/tests/procsub.right
@@ -1,7 +1,6 @@
test1
foo
test2
-test3
test4
8
test5
@@ -27,3 +26,8 @@ extern
0
0
123
+bar1
+ouch
+bar2
+foo
+subshell
diff --git a/tests/procsub.tests b/tests/procsub.tests
index 01ba46a8..946d2c22 100644
--- a/tests/procsub.tests
+++ b/tests/procsub.tests
@@ -1,11 +1,25 @@
+# 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/>.
+#
# process substitution constructs that have caused problems in the past
. ./test-glue-functions
eval cat <(echo test1)
eval "echo foo;cat" <(echo test2)
-unset f
-f=<(echo test3); cat "$f"
+# this doesn't work, and it never should have
+#unset f
+#f=<(echo test3); cat "$f"
unset f
eval f=<(echo test4) "; cat \$f"
@@ -69,10 +83,10 @@ count_lines()
{
wc -l < $1
-# case "$1" in
-# *sh-np*) [ -e "$1" ] || { echo 0; echo 0; echo 0; echo 0; return; } ;;
-# *) ;;
-# esac
+ case "$1" in
+ *sh-np*) [ -e "$1" ] || { echo 0; echo 0; echo 0; echo 0; return; } ;;
+ *) ;;
+ esac
wc -l < $1
wc -l < $1
@@ -88,6 +102,7 @@ echo extern
FN=$TMPDIR/bashtest-$$
cat >$FN << \EOF
wc -l < $1
+case $1 in *sh-np*) [ -e $1 ] || { echo 0; echo 0; echo 0; echo 0; return; } ;; esac
wc -l < $1
wc -l < $1
true | wc -l < $1
@@ -103,3 +118,4 @@ moo() { ls -al "$1" >/dev/null; (true); ls -al "$1" >/dev/null; }; moo >(true)
unset -f moo
${THIS_SH} ./procsub1.sub
+${THIS_SH} ./procsub2.sub
diff --git a/tests/procsub2.sub b/tests/procsub2.sub
new file mode 100644
index 00000000..75ad2d0c
--- /dev/null
+++ b/tests/procsub2.sub
@@ -0,0 +1,36 @@
+# 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 whether or not we remove FIFOs and close pipe file descriptors too
+# aggressively
+
+ouch()
+{
+ while read foo; do echo "$foo"; done < <(echo bar1)
+ cat "$1"
+}
+
+ouch <(echo ouch )
+
+ouch2()
+{
+ { cat; } < <(echo bar2)
+ cat "$1"
+}
+
+exec 4< <(echo subshell)
+ouch2 <(echo foo )
+
+read var <&4
+echo $var
diff --git a/tests/quote.right b/tests/quote.right
index e4eb9bb9..303e685d 100644
--- a/tests/quote.right
+++ b/tests/quote.right
@@ -94,23 +94,29 @@ argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
+argv[2] = <>
argv[1] = <>
+argv[2] = <>
argv[1] = <>
=====
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
+argv[2] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
+argv[2] = <>
=====
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
+argv[2] = <>
argv[1] = <>
+argv[2] = <>
argv[1] = <>
=====
argv[1] = <>
@@ -118,5 +124,59 @@ argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
-argv[1] = <>
-argv[1] = <>
+argv[2] = <>
+argv[1] = <>
+argv[2] = <>
+argv[1] = <>
+argv[1] = <4>
+argv[2] = <>
+argv[1] = <ab>
+argv[2] = <>
+argv[1] = <ab>
+argv[2] = <>
+argv[1] = <ab>
+argv[2] = <>
+argv[1] = <ab>
+argv[2] = <>
+argv[1] = <ab ''>
+argv[1] = <ab >
+argv[1] = <ab ''>
+argv[1] = <ab >
+0
+1
+1
+1
+1
+1
+1
+1
+2
+2
+2
+2
+0
+1
+1
+1
+1
+1
+1
+1
+2
+2
+2
+2
+0
+0
+0
+2
+2
+4
+4
+3
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <^?>
diff --git a/tests/quote.tests b/tests/quote.tests
index d7f13cd0..0a0b4afe 100644
--- a/tests/quote.tests
+++ b/tests/quote.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
echo "Single Quote"
echo 'foo
bar'
@@ -122,3 +135,5 @@ echo ${foo:-string \\\}}
${THIS_SH} ./quote1.sub
${THIS_SH} ./quote2.sub
+${THIS_SH} ./quote3.sub
+${THIS_SH} ./quote4.sub
diff --git a/tests/quote1.sub b/tests/quote1.sub
index a9a1ef15..86f97869 100644
--- a/tests/quote1.sub
+++ b/tests/quote1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# inconsistency with quoted pattern substitution patterns through bash-4.2
# fixed in a ksh93-compatible (and Posix-compatible, in general) way
# NOT backwards compatible
diff --git a/tests/quote2.sub b/tests/quote2.sub
index 7deb4cfa..1012b8fe 100644
--- a/tests/quote2.sub
+++ b/tests/quote2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
x=x
e=
diff --git a/tests/quote3.sub b/tests/quote3.sub
new file mode 100644
index 00000000..54bc5ed4
--- /dev/null
+++ b/tests/quote3.sub
@@ -0,0 +1,31 @@
+# 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/>.
+#
+# new tests
+x=4
+sp=' '
+
+# word
+recho ${x}${sp}''
+
+# unquoted
+recho ${x+ab "$y"}
+recho ${x+ab ''}
+recho ${x+ab "$( : )"}
+recho ${x+ab "${yy}"}
+
+# quoted
+recho "${x+ab ''}"
+recho "${x+ab ""}"
+recho "${x+ab '${yy}'}"
+recho "${x+ab "${yy}"}"
diff --git a/tests/quote4.sub b/tests/quote4.sub
new file mode 100644
index 00000000..ab534c8e
--- /dev/null
+++ b/tests/quote4.sub
@@ -0,0 +1,101 @@
+# 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/>.
+#
+n() { echo $#; }
+
+set --
+
+n "$@"
+
+# should be 1
+n "$@"''
+n ''"$@"
+n ''"$@"''
+
+set -- ''
+
+n "$@"
+# should be 1
+n "$@"''
+n ''"$@"
+n ''"$@"''
+
+set -- '' ''
+
+n "$@"
+# should be 2
+n ''"$@"
+# should be 2
+n "$@"''
+# should be 2
+n ''"$@"''
+
+x=x
+
+set --
+
+n ${x+"$@"}
+
+# should be 1
+n ${x+"$@"''}
+n ${x+''"$@"}
+n ${x+''"$@"''}
+
+set -- ''
+
+n ${x+"$@"}
+# should be 1
+n ${x+"$@"''}
+n ${x+''"$@"}
+n ${x+''"$@"''}
+
+set -- '' ''
+
+n ${x+"$@"}
+# should be 2
+n ${x+''"$@"}
+# should be 2
+n ${x+"$@"''}
+# should be 2
+n ${x+''"$@"''}
+
+
+set --
+
+n "$@" "$@"
+n "$@""$@"
+
+n ${x+"$@" "$@"}
+
+set -- ''
+
+n ${x+"$@" "$@"}
+n "$@" "$@"
+
+set -- '' ''
+
+n ${x+"$@" "$@"}
+n "$@" "$@"
+n "$@""$@"
+
+# new tests
+unset -v x
+v=$'\177'
+
+recho ''$'\177'''
+recho $'\177'''
+recho ''$'\177'
+
+recho ''$v''
+recho ''$v
+recho $v''
diff --git a/tests/read.right b/tests/read.right
index 73cb7042..11440837 100644
--- a/tests/read.right
+++ b/tests/read.right
@@ -37,11 +37,11 @@ timeout 1: ok
timeout 2: ok
-./read2.sub: line 23: read: -3: invalid timeout specification
+./read2.sub: line 36: read: -3: invalid timeout specification
1
abcde
-./read3.sub: line 4: read: -1: invalid number
+./read3.sub: line 17: read: -1: invalid number
abc
ab
abc
diff --git a/tests/read.tests b/tests/read.tests
index f67cd00e..7384f05f 100644
--- a/tests/read.tests
+++ b/tests/read.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
echo " a " | (read x; echo "$x.")
echo " a b " | ( read x y ; echo -"$x"-"$y"- )
diff --git a/tests/read1.sub b/tests/read1.sub
index 2a36449b..b3b85157 100644
--- a/tests/read1.sub
+++ b/tests/read1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
a=7
echo 'abcdefg|xyz' | {
read -d '|' a
diff --git a/tests/read2.sub b/tests/read2.sub
index c4a1f771..41698e46 100644
--- a/tests/read2.sub
+++ b/tests/read2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
a=4
read -t 2 a < /dev/tty
diff --git a/tests/read3.sub b/tests/read3.sub
index af41e3f2..d413f7db 100644
--- a/tests/read3.sub
+++ b/tests/read3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# non-interactive
# error
diff --git a/tests/read5.sub b/tests/read5.sub
index e35674e0..e42a5be2 100644
--- a/tests/read5.sub
+++ b/tests/read5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
IFS=: read x y z << EOF
:::
EOF
diff --git a/tests/redir.right b/tests/redir.right
index d4ab60d5..8db10414 100644
--- a/tests/redir.right
+++ b/tests/redir.right
@@ -1,9 +1,9 @@
abc
-./redir.tests: line 15: /tmp/redir-test: cannot overwrite existing file
+./redir.tests: line 28: /tmp/redir-test: cannot overwrite existing file
abc
def
def
-./redir.tests: line 31: $z: ambiguous redirect
+./redir.tests: line 44: $z: ambiguous redirect
Point 1
Point 2
to a
@@ -24,8 +24,8 @@ read line3 "cd"
read line4 "daemon"
from stdin: aa
to stdout
-./redir4.sub: line 32: $fd: ambiguous redirect
-./redir4.sub: line 33: $fd: ambiguous redirect
+./redir4.sub: line 45: $fd: ambiguous redirect
+./redir4.sub: line 46: $fd: ambiguous redirect
err-and-out:
to stdout
to stderr
@@ -44,7 +44,20 @@ kl
ab
cd
cd
-./redir.tests: line 157: redir1.*: No such file or directory
+./redir.tests: line 170: redir1.*: No such file or directory
+# 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/>.
+#
# tests of ksh93-like dup-and-close redirection operators
exec 9<$0
@@ -85,7 +98,7 @@ f ()
done
}
after read
-# tests of ksh93-like dup-and-close redirection operators
+# This program is free software: you can redistribute it and/or modify
/
/
/
@@ -141,8 +154,10 @@ foo
1
7
after: 42
-./redir11.sub: line 40: $(ss= declare -i ss): ambiguous redirect
+./redir11.sub: line 53: $(ss= declare -i ss): ambiguous redirect
after: 42
a+=3
foo
foo
+./redir11.sub: line 75: 42: No such file or directory
+42
diff --git a/tests/redir.tests b/tests/redir.tests
index 6af02194..63bd4d37 100644
--- a/tests/redir.tests
+++ b/tests/redir.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${TMPDIR:=/tmp}
export LC_ALL=C
diff --git a/tests/redir10.sub b/tests/redir10.sub
index 27c48e82..7b1d682f 100644
--- a/tests/redir10.sub
+++ b/tests/redir10.sub
@@ -1,4 +1,16 @@
-#!/bin/bash
+# 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/>.
+#
#
# Out of file descriptors, because it forgets to close redirection. Only
# happens in a shell function. Problem through bash-4.2.
diff --git a/tests/redir11.sub b/tests/redir11.sub
index a919602c..d417cdb6 100644
--- a/tests/redir11.sub
+++ b/tests/redir11.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# make sure redirections do not have access to the temporary environment, even
# in subshells and command substitutions
@@ -52,3 +65,12 @@ a=2
a=9 eval echo foo >&$(echo $a)
a=2
a=9 eval echo foo '2>&1 >&$(echo $a)' | { grep -q 'Bad file' || echo 'redir11 bad 9'; }
+
+# double expansion of filenames when used in redirection error messages
+# present in bash versions back to at least bash-1.13
+# this is executed in the tests subdirectory of the source directory, so there
+# definitely should not be a file named `42'
+
+unset foo
+: <$((foo+=42))
+echo $foo
diff --git a/tests/redir3.sub b/tests/redir3.sub
index c486253e..b9fd0fd9 100644
--- a/tests/redir3.sub
+++ b/tests/redir3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
read line1
echo read line1 \"$line1\"
diff --git a/tests/redir4.sub b/tests/redir4.sub
index 14406d01..a4829856 100644
--- a/tests/redir4.sub
+++ b/tests/redir4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
minus=-
# standard input
diff --git a/tests/redir5.sub b/tests/redir5.sub
index ee7b045a..fa0f0c07 100644
--- a/tests/redir5.sub
+++ b/tests/redir5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# tests of ksh93-like dup-and-close redirection operators
exec 9<$0
diff --git a/tests/redir7.sub b/tests/redir7.sub
index 3fd371c7..65ca473b 100644
--- a/tests/redir7.sub
+++ b/tests/redir7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# weird redirections that caused trouble and were fixed in post-3.0 bash
stuff()
{
diff --git a/tests/redir8.sub b/tests/redir8.sub
index 88753f2f..d2d700cb 100644
--- a/tests/redir8.sub
+++ b/tests/redir8.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
cd ${TMPDIR:=/var/tmp}
rm -f u
diff --git a/tests/redir9.sub b/tests/redir9.sub
index 386ae56a..9050a94f 100644
--- a/tests/redir9.sub
+++ b/tests/redir9.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${TMPDIR:=/tmp}
func()
diff --git a/tests/rhs-exp.tests b/tests/rhs-exp.tests
index a28d7f03..6abdd2a7 100644
--- a/tests/rhs-exp.tests
+++ b/tests/rhs-exp.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
selvecs='&m68kcoff_vec'
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'$selvecs\'}"
diff --git a/tests/rhs-exp1.sub b/tests/rhs-exp1.sub
index 5631ea50..b194bf00 100644
--- a/tests/rhs-exp1.sub
+++ b/tests/rhs-exp1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# fixes for bugs in bash-4.2 regarding empty strings in expand_string_for_rhs
f=abc
diff --git a/tests/rsh.right b/tests/rsh.right
index a728f137..a91974a5 100644
--- a/tests/rsh.right
+++ b/tests/rsh.right
@@ -1,19 +1,19 @@
-./rsh1.sub: line 9: /bin/sh: restricted
-./rsh1.sub: line 11: sh: not found
-./rsh1.sub: line 12: a: command not found
-./rsh2.sub: line 10: hash: /bin/sh: restricted
-./rsh2.sub: line 12: hash: sh: not found
-./rsh2.sub: line 13: a: command not found
-./rsh.tests: line 12: cd: restricted
-./rsh.tests: line 13: PATH: readonly variable
-./rsh.tests: line 14: SHELL: readonly variable
-./rsh.tests: line 15: /bin/sh: restricted: cannot specify `/' in command names
-./rsh.tests: line 17: .: ./source.sub3: restricted
-./rsh.tests: line 20: /tmp/restricted: restricted: cannot redirect output
-./rsh.tests: line 24: /tmp/restricted: restricted: cannot redirect output
-./rsh.tests: line 29: command: -p: restricted
-./rsh.tests: line 31: set: +r: invalid option
+./rsh1.sub: line 22: /bin/sh: restricted
+./rsh1.sub: line 24: sh: not found
+./rsh1.sub: line 25: a: command not found
+./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 30: .: ./source.sub3: restricted
+./rsh.tests: line 33: /tmp/restricted: restricted: cannot redirect output
+./rsh.tests: line 37: /tmp/restricted: restricted: cannot redirect output
+./rsh.tests: line 42: command: -p: restricted
+./rsh.tests: line 44: set: +r: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
-./rsh.tests: line 32: set: restricted: invalid option name
-./rsh.tests: line 34: exec: restricted
+./rsh.tests: line 45: set: restricted: invalid option name
+./rsh.tests: line 47: exec: restricted
./rsh.tests: after exec
diff --git a/tests/rsh.tests b/tests/rsh.tests
index d1d77784..0d06fa1e 100644
--- a/tests/rsh.tests
+++ b/tests/rsh.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test restricted shell mode -- these should all be errors
#
# things not tested for:
diff --git a/tests/rsh1.sub b/tests/rsh1.sub
index fdd4ddd9..1539d740 100644
--- a/tests/rsh1.sub
+++ b/tests/rsh1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
cd ${TMPDIR:-/tmp}
cp /bin/sh .
diff --git a/tests/rsh2.sub b/tests/rsh2.sub
index 8c82c68b..7259dfbc 100644
--- a/tests/rsh2.sub
+++ b/tests/rsh2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
cd ${TMPDIR:-/tmp}
cp /bin/sh .
ln sh a
diff --git a/tests/run-all b/tests/run-all
index 34d3e4c8..b8219b2d 100644
--- a/tests/run-all
+++ b/tests/run-all
@@ -1,4 +1,18 @@
#! /bin/sh
+#
+# 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/>.
+#
: ${TMPDIR:=/tmp}
export TMPDIR
@@ -14,6 +28,7 @@ trap 'rm -f $BASH_TSTOUT' 0 1 2 3 15
PATH=.:$PATH # just to get recho/zecho/printenv if not run via `make tests'
export PATH
+
# unset BASH_ENV only if it is set
[ "${BASH_ENV+set}" = "set" ] && unset BASH_ENV
# can't reliably do it for SHELLOPTS; SHELLOPTS is readonly in bash
@@ -28,6 +43,9 @@ fi
: ${THIS_SH:=../bash}
export THIS_SH
+: ${BUILD_DIR:=..}
+export BUILD_DIR
+
${THIS_SH} ./version
rm -f ${BASH_TSTOUT}
diff --git a/tests/run-complete b/tests/run-complete
new file mode 100644
index 00000000..f1cef84e
--- /dev/null
+++ b/tests/run-complete
@@ -0,0 +1,2 @@
+${THIS_SH} ./complete.tests > ${BASH_TSTOUT} 2>&1
+diff ${BASH_TSTOUT} complete.right && rm -f ${BASH_TSTOUT}
diff --git a/tests/run-dbg-support b/tests/run-dbg-support
index 9e9c649c..af64517d 100644
--- a/tests/run-dbg-support
+++ b/tests/run-dbg-support
@@ -1,5 +1,3 @@
-#!../bash
-#$Id: run-dbg-support,v 1.5 2002/11/14 06:08:16 rockyb Exp $
TEST_NAME='dbg-support'
TEST_FILE="/tmp/${TEST_NAME}.check"
diff --git a/tests/run-dbg-support2 b/tests/run-dbg-support2
index f62583f8..375c32f9 100644
--- a/tests/run-dbg-support2
+++ b/tests/run-dbg-support2
@@ -1,5 +1,3 @@
-#!../bash
-#$Id: run-dbg-support2,v 1.3 2002/11/14 06:08:16 rockyb Exp $
TEST_NAME='dbg-support2'
TEST_FILE="/tmp/${TEST_NAME}.check"
@@ -9,8 +7,3 @@ diff $TEST_FILE ${TEST_NAME}.right && rm -f $TEST_FILE
# Return code tells testing mechanism whether passed or not.
exit $?
-
-#;;; Local Variables: ***
-#;;; mode:shell-script ***
-#;;; eval: (sh-set-shell "bash") ***
-#;;; End: ***
diff --git a/tests/run-minimal b/tests/run-minimal
index bbb9da18..ade30b15 100644
--- a/tests/run-minimal
+++ b/tests/run-minimal
@@ -1,5 +1,19 @@
#! /bin/sh
#
+# 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/>.
+#
+#
# run-minimal - a version of run-all for shells configured with
# --enable-minimal-config
#
@@ -26,6 +40,9 @@ export PATH
: ${THIS_SH:=../bash}
export THIS_SH
+: ${BUILD_DIR:=..}
+export BUILD_DIR
+
${THIS_SH} ./version.mini
rm -f "$BASH_TSTOUT"
diff --git a/tests/run-precedence b/tests/run-precedence
index de33224e..06ac343f 100644
--- a/tests/run-precedence
+++ b/tests/run-precedence
@@ -1,2 +1,2 @@
-${THIS_SH} ./precedence > ${BASH_TSTOUT}
+${THIS_SH} ./precedence.tests > ${BASH_TSTOUT}
diff ${BASH_TSTOUT} prec.right && rm -f ${BASH_TSTOUT}
diff --git a/tests/run-varenv b/tests/run-varenv
index f147d70b..be394cc7 100644
--- a/tests/run-varenv
+++ b/tests/run-varenv
@@ -1,2 +1,4 @@
+echo "warning: some of these tests will fail if arrays have not" >&2
+echo "warning: been compiled into the shell" >&2
${THIS_SH} ./varenv.tests 2>&1 | grep -v '^expect' > ${BASH_TSTOUT}
diff ${BASH_TSTOUT} varenv.right && rm -f ${BASH_TSTOUT}
diff --git a/tests/run-vredir b/tests/run-vredir
index 2a4faf30..2bdc1b83 100644
--- a/tests/run-vredir
+++ b/tests/run-vredir
@@ -1,2 +1,4 @@
+echo "warning: the text of a system error message may vary between systems and" >&2
+echo "warning: produce diff output." >&2
${THIS_SH} ./vredir.tests > ${BASH_TSTOUT} 2>&1
diff ${BASH_TSTOUT} vredir.right && rm -f ${BASH_TSTOUT}
diff --git a/tests/set-e.tests b/tests/set-e.tests
index d38edf6c..3e0d6698 100644
--- a/tests/set-e.tests
+++ b/tests/set-e.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
if : ; then
set -e
N=95
diff --git a/tests/set-e1.sub b/tests/set-e1.sub
index a8005607..cdd4d635 100644
--- a/tests/set-e1.sub
+++ b/tests/set-e1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# subshell failure should cause the shell to exit silently
${THIS_SH} -ce '(exit 17) ; echo "after (exit 17): $?"'
diff --git a/tests/set-x.tests b/tests/set-x.tests
index 531c53f6..3723552d 100755..100644
--- a/tests/set-x.tests
+++ b/tests/set-x.tests
@@ -1,4 +1,17 @@
-#!../bash
+# 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/>.
+#
+
# $Id: set-x.tests,v 1.1 2002/12/09 13:12:37 rockyb Exp $
#
# Test that "set -x" shows what we think it should.
diff --git a/tests/set-x1.sub b/tests/set-x1.sub
index b2aa2167..cb7fa827 100644
--- a/tests/set-x1.sub
+++ b/tests/set-x1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${TMPDIR:=/var/tmp}
TRACEFILE=$TMPDIR/bash-trace-$$
trap 'rm -f $TRACEFILE' 0 1 2 3 6 15
diff --git a/tests/shopt.right b/tests/shopt.right
index 08db75f1..8cf46db6 100644
--- a/tests/shopt.right
+++ b/tests/shopt.right
@@ -1,4 +1,4 @@
-./shopt.tests: line 2: shopt: -z: invalid option
+./shopt.tests: line 15: shopt: -z: invalid option
shopt: usage: shopt [-pqsu] [-o] [optname ...]
--
shopt -u autocd
@@ -292,5 +292,7 @@ verbose off
vi off
xtrace off
--
-./shopt.tests: line 93: shopt: xyz1: invalid shell option name
-./shopt.tests: line 94: shopt: xyz1: invalid option name
+./shopt.tests: line 106: shopt: xyz1: invalid shell option name
+./shopt.tests: line 107: shopt: xyz1: invalid option name
+expand_aliases on
+expand_aliases on
diff --git a/tests/shopt.tests b/tests/shopt.tests
index d4f2a8b1..c31870cf 100644
--- a/tests/shopt.tests
+++ b/tests/shopt.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# let's try an error message first
shopt -z
@@ -92,3 +105,9 @@ shopt -u -o
builtin printf -- "--\n"
shopt -p xyz1
shopt -o -p xyz1
+
+${THIS_SH} ./shopt1.sub
+
+# test whether or not temporary variable assignments that manipulate posix
+# mode restore the previous state or the default non-posix state
+${THIS_SH} -c 'shopt -s expand_aliases ; shopt expand_aliases ; POSIXLY_CORRECT=y true ; shopt expand_aliases'
diff --git a/tests/shopt1.sub b/tests/shopt1.sub
new file mode 100644
index 00000000..8c1150fb
--- /dev/null
+++ b/tests/shopt1.sub
@@ -0,0 +1,52 @@
+# 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/>.
+#
+
+# verify all shopt options are reset properly when the shell is reinitialized
+
+: ${TMPDIR:=/var/tmp} ${THIS_SH:=$PWD/bash}
+
+t1=$(mktemp)
+t2=$(mktemp)
+
+if [ ! -e "$t1" ] ; then
+ S1=$RANDOM
+ S2=$RANDOM
+ t1=$TMPDIR/s-$S1
+ t2=$TMPDIR/s-$S2
+ touch "$t1" "$t2"
+fi
+
+chmod +x "$t1" "$t2"
+
+echo "shopt" > "$t1"
+
+echo "#!${THIS_SH}" > "$t2"
+echo "shopt" >> "$t2"
+
+for o in $(compgen -A shopt)
+do
+ case $o in
+ extdebug) ;;
+ *) shopt -s $o ;;
+ esac
+done
+diff <("$t1") <("$t2")
+
+for o in $(compgen -A shopt)
+do
+ shopt -u $o;
+done
+diff <("$t1") <("$t2")
+
+rm "$t1" "$t2"
diff --git a/tests/source5.sub b/tests/source5.sub
index e6188094..4149c11f 100644
--- a/tests/source5.sub
+++ b/tests/source5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
LC_ALL=en_US.UTF-8
unset LC_ALL
unset LANG
@@ -6,7 +19,7 @@ export LANG=C
set +o posix
-# attempting to source a non-existant file is not an error...
+# attempting to source a non-existent file is not an error...
. /tmp/source-notthere
echo after bad source 1
diff --git a/tests/source6.sub b/tests/source6.sub
index 43db2031..24372927 100644
--- a/tests/source6.sub
+++ b/tests/source6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# tests sourcing non-regular files, fixed post-3.2
: ${TMPDIR:=/tmp}
diff --git a/tests/source7.sub b/tests/source7.sub
index 8ca0aeff..474a66f7 100644
--- a/tests/source7.sub
+++ b/tests/source7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
shopt -s expand_aliases
: ${TMPDIR:=/var/tmp}
diff --git a/tests/strip.tests b/tests/strip.tests
index b669b52e..b16705f4 100644
--- a/tests/strip.tests
+++ b/tests/strip.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
v=`echo "" ; echo "" ; echo ""`
echo "'$v'"
v=`echo -n " ab "`
diff --git a/tests/test.right b/tests/test.right
index 9832bd6d..391edbbd 100644
--- a/tests/test.right
+++ b/tests/test.right
@@ -233,48 +233,48 @@ t -G /tmp/test.group
t -h /tmp/test.symlink
0
t 4+3 -eq 7
-./test.tests: line 13: test: 4+3: integer expression expected
+./test.tests: line 26: test: 4+3: integer expression expected
2
b 4-5 -eq 7
-./test.tests: line 7: [: 4+3: integer expression expected
+./test.tests: line 20: [: 4+3: integer expression expected
2
t 9 -eq 4+5
-./test.tests: line 13: test: 4+5: integer expression expected
+./test.tests: line 26: test: 4+5: integer expression expected
2
b 9 -eq 4+5
-./test.tests: line 7: [: 4+5: integer expression expected
+./test.tests: line 20: [: 4+5: integer expression expected
2
t A -eq 7
-./test.tests: line 13: test: A: integer expression expected
+./test.tests: line 26: test: A: integer expression expected
2
b A -eq 7
-./test.tests: line 7: [: A: integer expression expected
+./test.tests: line 20: [: A: integer expression expected
2
t 9 -eq B
-./test.tests: line 13: test: B: integer expression expected
+./test.tests: line 26: test: B: integer expression expected
2
b 9 -eq B
-./test.tests: line 7: [: B: integer expression expected
+./test.tests: line 20: [: B: integer expression expected
2
t ( 1 = 2
-./test.tests: line 13: test: `)' expected
+./test.tests: line 26: test: `)' expected
2
b ( 1 = 2
-./test.tests: line 7: [: `)' expected, found ]
+./test.tests: line 20: [: `)' expected, found ]
2
-./test.tests: line 13: test: a: unary operator expected
+./test.tests: line 26: test: a: unary operator expected
2
-./test.tests: line 13: test: b: binary operator expected
+./test.tests: line 26: test: b: binary operator expected
2
-./test.tests: line 13: test: -A: unary operator expected
+./test.tests: line 26: test: -A: unary operator expected
2
-./test.tests: line 13: test: too many arguments
+./test.tests: line 26: test: syntax error: `-ne' unexpected
2
-./test.tests: line 13: test: too many arguments
+./test.tests: line 26: test: too many arguments
2
-./test.tests: line 418: [: missing `]'
+./test.tests: line 431: [: missing `]'
2
-./test.tests: line 13: test: (: unary operator expected
+./test.tests: line 26: test: (: unary operator expected
2
t -t a
1
diff --git a/tests/test.tests b/tests/test.tests
index 07a87a0b..03e2754a 100644
--- a/tests/test.tests
+++ b/tests/test.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
if (( $UID == 0 )); then
echo "test-tests: the test suite should not be run as root" >&2
fi
@@ -166,7 +179,7 @@ echo 't -S /tmp/test.socket'
t -S /tmp/test.socket # false
rm -f /tmp/test.socket
-touch /tmp/test.newer
+touch /tmp/test.newer ; sleep 1; echo "hello" > /tmp/test.newer
echo 't -N /tmp/test.newer'
t -N /tmp/test.newer
rm -f /tmp/test.newer
diff --git a/tests/test1.sub b/tests/test1.sub
index a1c58170..d25e0dc7 100644
--- a/tests/test1.sub
+++ b/tests/test1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# some systems, like old SunOS, have stat on /dev/fd/N and fstat(N, ...)
# return different results
: ${TMPDIR:=/tmp}
diff --git a/tests/tilde.right b/tests/tilde.right
index 49549b40..1301c0b0 100644
--- a/tests/tilde.right
+++ b/tests/tilde.right
@@ -24,3 +24,5 @@ ok 1
ok 2
ok 3
~root
+foo=bar:/usr/xyz
+foo=bar:~
diff --git a/tests/tilde.tests b/tests/tilde.tests
index 8a9f1369..374f3e6d 100644
--- a/tests/tilde.tests
+++ b/tests/tilde.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
wdir=$PWD
# this is needed because posix mode restricts tilde expansion to assignment
# statements preceding a command, instead of the default of expanding all
@@ -72,4 +85,8 @@ USER=root # should exist just about everywhere
echo ~$USER
cd "$wdir"
+
+echo foo=bar:~
+set -o posix; echo foo=bar:~
+
exit 0
diff --git a/tests/tilde2.tests b/tests/tilde2.tests
index ff6c76f0..cc5dba9f 100644
--- a/tests/tilde2.tests
+++ b/tests/tilde2.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
HOME=/usr/xyz
XPATH=/bin:/usr/bin:.
diff --git a/tests/trap.right b/tests/trap.right
index 41658293..4338ff4c 100644
--- a/tests/trap.right
+++ b/tests/trap.right
@@ -5,9 +5,9 @@ trap -- 'echo aborting' SIGINT
trap -- 'echo aborting' SIGQUIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
-[20] debug
+[33] debug
debug line
-[22] debug
+[35] debug
trap -- 'echo exiting' EXIT
trap -- 'echo aborting' SIGHUP
trap -- 'echo aborting' SIGINT
@@ -15,10 +15,10 @@ trap -- 'echo aborting' SIGQUIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
trap -- 'echo [$LINENO] debug' DEBUG
-[24] debug
-func[16] funcdebug
+[37] debug
+func[29] funcdebug
funcdebug line
-./trap.tests[26] funcdebug
+./trap.tests[39] funcdebug
trap -- 'echo exiting' EXIT
trap -- 'echo aborting' SIGHUP
trap -- 'echo aborting' SIGINT
@@ -26,14 +26,14 @@ trap -- 'echo aborting' SIGQUIT
trap -- 'echo aborting' SIGABRT
trap -- 'echo aborting' SIGTERM
trap -- 'echo ${FUNCNAME:-$0}[$LINENO] funcdebug' DEBUG
-./trap.tests[28] funcdebug
-./trap.tests[33] debug
-./trap.tests[34] debug
-func2[30] debug
-func2[31] debug
+./trap.tests[41] funcdebug
+./trap.tests[46] debug
+./trap.tests[47] debug
+func2[43] debug
+func2[44] debug
func2debug line
-./trap.tests[36] debug
-./trap.tests[38] debug
+./trap.tests[49] debug
+./trap.tests[51] debug
trap -- 'echo exiting' EXIT
trap -- 'echo aborting' SIGHUP
trap -- 'echo aborting' SIGINT
@@ -76,8 +76,8 @@ ERRTRAP
1
+[7] echo 2
2
-+[8] echo 3
-+[8] cat
++[8] false
++[8] false
+[8] false
++[8] echo trap: 8
trap: 8
diff --git a/tests/trap.tests b/tests/trap.tests
index 637bfd28..4f808be3 100644
--- a/tests/trap.tests
+++ b/tests/trap.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test the trap code
trap 'echo exiting' 0
diff --git a/tests/trap2.sub b/tests/trap2.sub
index 0f1f2d96..bd9a76be 100755
--- a/tests/trap2.sub
+++ b/tests/trap2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set +e
trap 'echo ERRTRAP' ERR
diff --git a/tests/trap3.sub b/tests/trap3.sub
index 0df44550..1490a76b 100644
--- a/tests/trap3.sub
+++ b/tests/trap3.sub
@@ -5,5 +5,5 @@ set -x
echo 1
echo 2
-echo 3 | cat | false
+false | false | false
echo 4
diff --git a/tests/trap4.sub b/tests/trap4.sub
index ab5ca3e3..c84b54e1 100644
--- a/tests/trap4.sub
+++ b/tests/trap4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# make sure subshells at the end of pipelines run any exit traps they set
: | { trap 'echo exit subshell 1' EXIT; exit; }; echo current shell
diff --git a/tests/trap5.sub b/tests/trap5.sub
index 7f3380b4..826b794c 100644
--- a/tests/trap5.sub
+++ b/tests/trap5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# make sure process substitution runs the exit trap
[[ -n $(< <(trap "cat /dev/fd/0" EXIT)) ]] <<<works && echo works || echo "fail :("
diff --git a/tests/trap6.sub b/tests/trap6.sub
index 332a1773..72685580 100644
--- a/tests/trap6.sub
+++ b/tests/trap6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -o functrace
fn() { return; }
diff --git a/tests/type.right b/tests/type.right
index 7ec6bfba..f876715a 100644
--- a/tests/type.right
+++ b/tests/type.right
@@ -1,6 +1,6 @@
-./type.tests: line 9: type: -r: invalid option
+./type.tests: line 22: type: -r: invalid option
type: usage: type [-afptP] name [name ...]
-./type.tests: line 12: type: notthere: not found
+./type.tests: line 25: type: notthere: not found
function
keyword
builtin
@@ -24,7 +24,7 @@ func ()
}
while
while is a shell keyword
-./type.tests: line 43: type: m: not found
+./type.tests: line 56: type: m: not found
alias m='more'
alias m='more'
m is aliased to `more'
@@ -37,15 +37,15 @@ builtin
builtin is a shell builtin
/bin/sh
/bin/sh is /bin/sh
-./type.tests: line 65: type: func: not found
-./type.tests: line 67: type: m: not found
+./type.tests: line 78: type: func: not found
+./type.tests: line 80: type: m: not found
/bin/sh
/tmp/bash
bash is hashed (/tmp/bash)
file
hits command
- 3 /tmp/bash
1 /bin/sh
+ 3 /tmp/bash
f is a function
f ()
{
diff --git a/tests/type.tests b/tests/type.tests
index 1c03e018..fd39c18a 100644
--- a/tests/type.tests
+++ b/tests/type.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set +o posix
hash -r
diff --git a/tests/type2.sub b/tests/type2.sub
index 3f85ead7..34977c51 100644
--- a/tests/type2.sub
+++ b/tests/type2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
foo()
{
echo
diff --git a/tests/type3.sub b/tests/type3.sub
index 442f22e4..1a95de38 100644
--- a/tests/type3.sub
+++ b/tests/type3.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
cd ${TMPDIR:-/tmp}
foo() {
diff --git a/tests/type4.sub b/tests/type4.sub
index ed5bcf6a..937f9980 100644
--- a/tests/type4.sub
+++ b/tests/type4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
bb()
{
(
diff --git a/tests/unicode1.sub b/tests/unicode1.sub
index baa92eaa..fc742855 100644
--- a/tests/unicode1.sub
+++ b/tests/unicode1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
unset LC_ALL
ErrorCnt=0
diff --git a/tests/unicode2.sub b/tests/unicode2.sub
index 83ff2747..16dd604a 100644
--- a/tests/unicode2.sub
+++ b/tests/unicode2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
. ./test-glue-functions
export LANG=en_US.UTF-8
diff --git a/tests/varenv.right b/tests/varenv.right
index ca7d4cf1..358f5dc7 100644
--- a/tests/varenv.right
+++ b/tests/varenv.right
@@ -22,8 +22,8 @@ AVAR
AVAR
42
/bin:/usr/bin:/usr/local/bin:.
-avar=([0]="/bin:/usr/bin:/usr/local/bin:.")
-z=yy
+declare -a avar=([0]="/bin:/usr/bin:/usr/local/bin:.")
+declare -- z="yy"
42
declare -i ivar="10"
unset
@@ -60,7 +60,8 @@ FIN: asdf fdsa, asdf fdsa
g: v = , w =
f: v = , w =
FIN: v = two, w = one
-./varenv4.sub: line 54: bbb: unique: cannot convert indexed to associative array
+./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
declare -Ar FOOBAR=([foo]="bar" )
declare -Ar FOOBAR=([foo]="bar" )
@@ -77,7 +78,7 @@ declare -ar myvar=([0]="0")
declare -ir myvar="1"
declare -rx tempvar1='foo'
declare -rx tempvar2='qux'
-./varenv7.sub: line 44: local: var: readonly variable
+./varenv7.sub: line 57: local: var: readonly variable
inside: outside
outside: outside
local: unset1 unset2
@@ -95,30 +96,30 @@ in o1 (readonly modifying local scalars):
declare -r i1="a b c"
declare -r j1="1 2 3"
after o1:
-./varenv9.sub: line 15: declare: i1: not found
-./varenv9.sub: line 15: declare: j1: not found
+./varenv9.sub: line 28: declare: i1: not found
+./varenv9.sub: line 28: declare: j1: not found
in o2 (readonly setting global scalars):
declare -r i2="a b c"
declare -r j2="1 2 3"
after o2:
declare -r i2="a b c"
declare -r j2="1 2 3"
-./varenv9.sub: line 33: unset: i2: cannot unset: readonly variable
-./varenv9.sub: line 33: unset: j2: cannot unset: readonly variable
+./varenv9.sub: line 46: unset: i2: cannot unset: readonly variable
+./varenv9.sub: line 46: unset: j2: cannot unset: readonly variable
in o3 (readonly modifying locals, converting to arrays):
declare -ar i3=([0]="a" [1]="b" [2]="c")
declare -ar j3=([0]="1" [1]="2" [2]="3")
after o3:
-./varenv9.sub: line 48: declare: i3: not found
-./varenv9.sub: line 48: declare: j3: not found
+./varenv9.sub: line 61: declare: i3: not found
+./varenv9.sub: line 61: declare: j3: not found
in o4 (readonly setting global array variables):
declare -ar i4=([0]="a" [1]="b" [2]="c")
declare -ar j4=([0]="1" [1]="2" [2]="3")
after o4:
declare -ar i4=([0]="a" [1]="b" [2]="c")
declare -ar j4=([0]="1" [1]="2" [2]="3")
-./varenv9.sub: line 66: unset: i4: cannot unset: readonly variable
-./varenv9.sub: line 66: unset: j4: cannot unset: readonly variable
+./varenv9.sub: line 79: unset: i4: cannot unset: readonly variable
+./varenv9.sub: line 79: unset: j4: cannot unset: readonly variable
main: unset
inner: res unset
outer: res: X Y
@@ -128,13 +129,14 @@ outer: res: X Y
main: after second call: X
func: null or unset
after func: x = outside
-./varenv11.sub: line 4: local: qux: readonly variable
-./varenv11.sub: line 5: qux: readonly variable
+./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=([zero]="zero" [one]="one" )
declare -a bar=([0]="zero" [1]="one")
-declare -A foo=([zero]="zero" [one]="one" )
+declare -A foo=([one]="one" [zero]="zero" )
declare -a bar=([0]="zero" [1]="one")
-./varenv11.sub: line 29: a: readonly variable
+./varenv11.sub: line 42: a: readonly variable
foo=abc
func1: var =
@@ -147,30 +149,38 @@ inside: declare -x var="value"
outside: declare -- var="one"
inside: declare -x var="value"
outside: declare -- var="outside"
-inside: declare -x var="global"
+inside: declare -x var="inside"
outside: declare -- var="outside"
-foo=<unset> environment foo=
-foo=foo environment foo=foo
-foo=foo environment foo=foo
-./varenv13.sub: line 3: `var[0]': not a valid identifier
-./varenv13.sub: line 3: `var[@]': not a valid identifier
-./varenv13.sub: line 1: declare: var: not found
-./varenv13.sub: line 12: var[@]: bad array subscript
+outside 1.0: var=one
+outside 1.1: var=one
+inside func: var=two
+outside 2.0: var=<unset>
+inside func: var=two
+outside 2.1: var=global
+inside func1: var=value
+outside 3.0: var=value
+inside func2: var=global
+outside 4.0: var=outside
+foo: hello world
+after foo: var=global
+bar: hello world
+after bar: var=global
+./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
+./varenv13.sub: line 25: var[@]: bad array subscript
declare -A var=([0]="X" )
help
-./varenv13.sub: line 21: `var[0]': not a valid identifier
+./varenv13.sub: line 34: `var[0]': not a valid identifier
1
-./varenv14.sub: line 6: warning: var: cannot inherit value from incompatible type
-declare -a var=([0]="X")
-./varenv14.sub: line 9: warning: var: cannot inherit value from incompatible type
-declare -a var=([0]="Y")
-./varenv14.sub: line 10: warning: var: cannot inherit value from incompatible type
-declare -a var=([0]="Y")
-./varenv14.sub: line 11: warning: var: cannot inherit value from incompatible type
-declare -a var=()
-./varenv14.sub: line 12: warning: var: cannot inherit value from incompatible type
-declare -a var=()
-./varenv14.sub: line 18: f: var: cannot convert indexed to associative array
+declare -A var=([0]="X" )
+declare -A var=([Y]="Y" )
+declare -A var=([Y]="Y" )
+declare -A var=()
+declare -A var=()
+./varenv14.sub: line 31: f: var: cannot convert indexed to associative array
+./varenv14.sub: line 31: declare: var: cannot convert indexed to associative array
+declare -a var=([0]="12")
declare -a a=([0]="X")
declare -a s=([0]="X")
declare -a a=([0]="X" [1]="Y")
@@ -207,6 +217,54 @@ after source 1: a b c d e f g h i j k l m n o p q r s t u v w x y z
varenv15.in: before set: one two three four five six seven eight nine ten
varenv15.in: after set: a b c d e f g h i j k l m n o p q r s t u v w x y z
after source 2: a b c d e f g h i j k l m n o p q r s t u v w x y z
+foo=showfoo environment foo=showfoo
+foo=showfoo environment foo=showfoo
+foo=showfoo environment foo=showfoo
+outside: foo=<unset>
+
+posix mode
+foo=showfoo environment foo=showfoo
+outside 1.0: foo=<unset>
+foo=showfoo environment foo=showfoo
+foo=showfoo environment foo=showfoo
+outside 1.1: foo=<unset>
+foo=<unset> environment foo=
+outside 2.0: foo=<unset>
+foo=foo environment foo=foo
+foo=<unset> environment foo=
+outside 2.1: foo=<unset>
+declare -- var="global"
+declare -- var
+declare -- var="local"
+declare -- var="global"
+declare -- var="local"
+declare -- var
+declare -- var="local"
+declare -- var
+declare -- var="local"
+declare -- var
+declare -- var="local"
+declare -- var="f1"
+declare -- var="local"
+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")
+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
+declare -x v="x"
+declare -x v="t"
+declare -- v
+declare -x v
+ignoreeof on
+ignoreeof off
+ignoreeof on
+10
+match 1
a=z
a=b
a=z
diff --git a/tests/varenv.tests b/tests/varenv.tests
index 34b85596..b058ed4f 100644
--- a/tests/varenv.tests
+++ b/tests/varenv.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
#
# varenv.sh
#
@@ -234,13 +247,18 @@ ${THIS_SH} ./varenv11.sub
# temporary environment variable propagation and scoping in posix mode
${THIS_SH} ./varenv12.sub
-# temporary environment and invalid shell indentifier names
+# temporary environment and invalid shell identifier names
${THIS_SH} ./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
# make sure variable scoping is done right
tt() { typeset a=b;echo a=$a; };a=z;echo a=$a;tt;echo a=$a
diff --git a/tests/varenv1.sub b/tests/varenv1.sub
index 168f87b1..8def153a 100644
--- a/tests/varenv1.sub
+++ b/tests/varenv1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# test out the export behavior of variable assignments preceding `eval', `.'
# and shell functions
diff --git a/tests/varenv10.sub b/tests/varenv10.sub
index 887cfd2c..aa0175af 100644
--- a/tests/varenv10.sub
+++ b/tests/varenv10.sub
@@ -1,7 +1,19 @@
-#!/bin/bash
+# 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/>.
+#
#
# various tests of unset when applied to variables at different local scopes
-
+#
# function unsetting variable at previous local scope, uncovering global
inner()
diff --git a/tests/varenv11.sub b/tests/varenv11.sub
index d4384983..638aa2c7 100644
--- a/tests/varenv11.sub
+++ b/tests/varenv11.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# couple of errors here
func()
{
diff --git a/tests/varenv12.sub b/tests/varenv12.sub
index edba3c94..92b3692f 100644
--- a/tests/varenv12.sub
+++ b/tests/varenv12.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
set -o posix
fn() { foo=abc : ; typeset +x foo; printenv|grep ^foo=; }
@@ -50,10 +63,11 @@ unset -f func
# this will probably change behavior; export shouldn't behave like this when
# not in posix mode and the sequencing is probably wrong in posix mode. since
# export is a special builtin, the variable assignment should modify the
-# global variable, leaving the local variable unchanged. all shells, including
-# bash, modify the local variable; bash is the only one that propagates the
-# value out to the calling environment. bash does that only when in posix
-# mode.
+# local variable, as if a standalone assignment statement had been executed
+# (posix modifying "the current execution environment") leaving the global
+# variable unchanged. all shells, including bash, modify the local variable;
+# bash was the only one that propagates the value out to the calling
+# environment, but no longer does so.
func()
{
@@ -72,7 +86,7 @@ unset -f func
func()
{
local var=local
- var=global :
+ var=inside :
echo -n 'inside: ' ; declare -p var
}
@@ -83,18 +97,75 @@ echo -n 'outside: ' ; declare -p var
unset -v var
unset -f func
-# test whether or not temporary environment assignments are exported
-# in posix mode
-showfoo()
+func()
{
- printf %s "foo=${foo-<unset>}"
- echo -n ' environment foo='
- printenv foo || echo
+ echo -n 'inside func: ' ; echo "var=${var-<unset>}"
}
-unset foo
-showfoo
-foo=foo showfoo
-showfoo
-unset -v foo
-unset -f showfoo
+unset -v var
+var=one :
+echo -n 'outside 1.0: ' ; echo "var=${var-<unset>}"
+
+unset -v var
+var=one eval ':'
+echo -n 'outside 1.1: ' ; echo "var=${var-<unset>}"
+
+unset -v var
+
+var=two func
+echo -n 'outside 2.0: ' ; echo "var=${var-<unset>}"
+var=global
+var=two func
+echo -n 'outside 2.1: ' ; echo "var=${var-<unset>}"
+
+unset -v var
+unset -f func
+
+func1()
+{
+ var=value export var
+ echo -n 'inside func1: ' ; echo "var=${var-<unset>}"
+}
+
+var=outside
+func1
+echo -n 'outside 3.0: ' ; echo "var=${var-<unset>}"
+
+unset -v var
+unset -f func1
+
+func2()
+{
+ local var=local
+ var=global :
+ echo -n 'inside func2: ' ; echo "var=${var-<unset>}"
+}
+
+var=outside
+func2
+echo -n 'outside 4.0: ' ; echo "var=${var-<unset>}"
+
+unset -v var
+unset -f fecho foo bar
+
+fecho() {
+ echo $var
+}
+
+foo() {
+ local var="foo: bye bye"
+ var="foo: hello world" fecho
+}
+
+bar() {
+ var="bar: hello world" fecho
+}
+
+var=global
+var=outside foo
+echo after foo: var=$var
+var=global
+var=outside bar
+echo after bar: var=$var
+
+unset -v var
diff --git a/tests/varenv13.sub b/tests/varenv13.sub
index 0e6a42c1..1f837ec7 100644
--- a/tests/varenv13.sub
+++ b/tests/varenv13.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
f() { declare -p ${!var*} | grep ^var; declare -p var ; }
var[0]=X var[@]=Y f
diff --git a/tests/varenv14.sub b/tests/varenv14.sub
index 52b20d81..091c4700 100644
--- a/tests/varenv14.sub
+++ b/tests/varenv14.sub
@@ -1,4 +1,17 @@
-# testing framework for local variable inheritence
+# 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/>.
+#
+# testing framework for local variable inheritance
shopt -s localvar_inherit
declare -A var
diff --git a/tests/varenv15.sub b/tests/varenv15.sub
index 52c8a940..4c9ef0e4 100644
--- a/tests/varenv15.sub
+++ b/tests/varenv15.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# check saving and restoring positional parameters around function calls
f()
diff --git a/tests/varenv16.sub b/tests/varenv16.sub
new file mode 100644
index 00000000..847926c9
--- /dev/null
+++ b/tests/varenv16.sub
@@ -0,0 +1,51 @@
+# 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 whether or not temporary environment assignments are exported
+# in posix mode. works now, posix says it will not work in the future
+
+show2()
+{
+ printf %s "foo=${foo-<unset>}"
+ echo -n ' environment foo='
+ printenv foo || echo
+}
+
+showfoo()
+{
+ local foo
+
+ foo=showfoo show2
+}
+
+unset foo
+showfoo
+foo=foo showfoo
+showfoo
+echo outside: "foo=${foo-<unset>}"
+
+echo ; echo 'posix mode'
+set -o posix
+unset foo
+showfoo
+echo outside 1.0: "foo=${foo-<unset>}"
+foo=foo showfoo
+showfoo
+echo outside 1.1: "foo=${foo-<unset>}"
+
+unset foo
+show2
+echo outside 2.0: "foo=${foo-<unset>}"
+foo=foo show2
+show2
+echo outside 2.1: "foo=${foo-<unset>}"
diff --git a/tests/varenv17.sub b/tests/varenv17.sub
new file mode 100644
index 00000000..1f9278cf
--- /dev/null
+++ b/tests/varenv17.sub
@@ -0,0 +1,44 @@
+# 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/>.
+#
+
+# testing -I and local variable inheritance
+var=global
+
+f()
+{
+ local $1 var
+ declare -p var
+
+ var=local
+ declare -p var
+}
+
+declare -I var
+declare -p var
+
+f
+f -I
+unset var
+f
+f -I
+
+f1()
+{
+ var=$FUNCNAME
+
+ f
+ f -I
+}
+
+f1
diff --git a/tests/varenv18.sub b/tests/varenv18.sub
new file mode 100644
index 00000000..4ad7f1a4
--- /dev/null
+++ b/tests/varenv18.sub
@@ -0,0 +1,41 @@
+# 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/>.
+#
+
+arr=(zero one two)
+four=four
+
+f()
+{
+ local -a arr=( "${arr[@]}" )
+ arr+=(three four five)
+ declare -p arr
+}
+f
+declare -p arr
+
+f1()
+{
+ local -a arr=(three $four five)
+ declare -p arr
+}
+f1
+
+set -u
+name='arr[@]'
+f2()
+{
+ local -a arr=("${!name}")
+ declare -p arr
+}
+f2
diff --git a/tests/varenv19.sub b/tests/varenv19.sub
new file mode 100644
index 00000000..753f508c
--- /dev/null
+++ b/tests/varenv19.sub
@@ -0,0 +1,51 @@
+# 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/>.
+#
+
+# variable attribute inheritance problems without specifying -a or -A
+
+function aaa() {
+ local x='1 2 3'
+ echo "aaa ${x}"
+}
+
+function bbb {
+ local x
+ x=(4 5 6)
+ echo "bbb ${x[*]}"
+}
+
+ccc()
+{
+ local x=(7 8 9)
+ echo "ccc ${x[*]}"
+}
+
+function ddd
+{
+ local -r x='0'
+ echo "ddd ${x}"
+ aaa
+ bbb
+ ccc
+}
+
+ddd
+
+f()
+{
+ local x=(one two three)
+ declare -p x
+}
+f
+declare -p x
diff --git a/tests/varenv2.sub b/tests/varenv2.sub
index b2935726..0fde5b20 100644
--- a/tests/varenv2.sub
+++ b/tests/varenv2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
fff()
{
typeset i=0 x=10
diff --git a/tests/varenv20.sub b/tests/varenv20.sub
new file mode 100644
index 00000000..5fba8c4c
--- /dev/null
+++ b/tests/varenv20.sub
@@ -0,0 +1,13 @@
+# tests of local variables with the same name as variables passed in the
+# temporary environment
+
+f() { local v=x; local -p; }
+v=t f
+
+f() { local v; declare -p v; }
+v=t f
+
+f() { local v=x; unset v; declare -p v; }
+v=g
+f
+v=t f
diff --git a/tests/varenv21.sub b/tests/varenv21.sub
new file mode 100644
index 00000000..613e4759
--- /dev/null
+++ b/tests/varenv21.sub
@@ -0,0 +1,48 @@
+# 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 behavior of `local -' inside shell functions
+
+IGNOREEOF=0
+shopt -o ignoreeof
+
+f()
+{
+ local -
+ set +o ignoreeof
+ shopt -o ignoreeof
+}
+
+f
+shopt -o ignoreeof
+echo $IGNOREEOF
+
+unset -f f
+
+f()
+{
+ local -
+ set -m -H +B
+ set -u
+}
+
+before="$-|$SHELLOPTS"
+f
+after="$-|$SHELLOPTS"
+
+case "$after" in
+$before) echo match 1 ;;
+*) echo bad 1 ;;
+esac
+
+unset -f f
diff --git a/tests/varenv3.sub b/tests/varenv3.sub
index 1384fcb1..854e483d 100644
--- a/tests/varenv3.sub
+++ b/tests/varenv3.sub
@@ -1,4 +1,16 @@
-#!/bin/bash
+# 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/>.
+#
oifs=$IFS
diff --git a/tests/varenv4.sub b/tests/varenv4.sub
index b2df61c9..9735b617 100644
--- a/tests/varenv4.sub
+++ b/tests/varenv4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
f()
{
local -a v
diff --git a/tests/varenv5.sub b/tests/varenv5.sub
index 8ebfa36d..b6eb70c2 100644
--- a/tests/varenv5.sub
+++ b/tests/varenv5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
function foobar {
declare -rgA FOOBAR=([foo]=bar)
declare -p FOOBAR
diff --git a/tests/varenv6.sub b/tests/varenv6.sub
index d0269fb6..8cf21f72 100644
--- a/tests/varenv6.sub
+++ b/tests/varenv6.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
f()
{
local str=F
diff --git a/tests/varenv7.sub b/tests/varenv7.sub
index 45654da2..4b259606 100644
--- a/tests/varenv7.sub
+++ b/tests/varenv7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
foo()
{
local -a myvar=()
diff --git a/tests/varenv9.sub b/tests/varenv9.sub
index eda1be3f..5837aa54 100644
--- a/tests/varenv9.sub
+++ b/tests/varenv9.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
# case 1: readonly modifying local scalar variables
o1() {
local i1 j1
diff --git a/tests/vredir.right b/tests/vredir.right
index f4fe0db8..b2c4cc9c 100644
--- a/tests/vredir.right
+++ b/tests/vredir.right
@@ -8,8 +8,8 @@ bar ()
exec {v}> $TMPFILE;
echo $v
}
-./vredir.tests: line 6: v: readonly variable
-./vredir.tests: line 6: v: cannot assign fd to variable
+./vredir.tests: line 19: v: readonly variable
+./vredir.tests: line 19: v: cannot assign fd to variable
42
bar is a function
bar ()
diff --git a/tests/vredir.tests b/tests/vredir.tests
index ce77deb7..ea59eecd 100644
--- a/tests/vredir.tests
+++ b/tests/vredir.tests
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${TMPDIR:=/var/tmp}
TMPFILE=$TMPDIR/foo
diff --git a/tests/vredir1.sub b/tests/vredir1.sub
index 403734c8..484f313b 100644
--- a/tests/vredir1.sub
+++ b/tests/vredir1.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
bar()
{
exec {v}<<EOF
diff --git a/tests/vredir2.sub b/tests/vredir2.sub
index e1a380df..4f9e7bb3 100644
--- a/tests/vredir2.sub
+++ b/tests/vredir2.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
: ${TMPDIR:=/var/tmp}
SHELLSFILE=$TMPDIR/shells-$$
diff --git a/tests/vredir4.sub b/tests/vredir4.sub
index e1cef057..f861bcfc 100644
--- a/tests/vredir4.sub
+++ b/tests/vredir4.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
swizzle()
{
fd0=0
diff --git a/tests/vredir5.sub b/tests/vredir5.sub
index d1531e91..beb45ac2 100644
--- a/tests/vredir5.sub
+++ b/tests/vredir5.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
swizzle()
{
exec {fd0}<&0
diff --git a/tests/vredir7.sub b/tests/vredir7.sub
index 8cb80edd..0f76f404 100644
--- a/tests/vredir7.sub
+++ b/tests/vredir7.sub
@@ -1,3 +1,16 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
swizzle()
{
exec {fd[0]}<&0