diff options
author | Chet Ramey <chet.ramey@case.edu> | 2020-09-09 15:25:32 -0400 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2020-09-09 15:25:32 -0400 |
commit | 3eb0018e75b74bb886df7fba4b1712529ce7258f (patch) | |
tree | 13b53713ef8f483a82295324e314da48b59c9346 /tests | |
parent | 712f80b0a49c3a0227d0b52bff5e0b763747697e (diff) | |
download | bash-5.1-beta.tar.gz |
bash-5.1 beta releasebash-5.1-beta
Diffstat (limited to 'tests')
-rw-r--r-- | tests/array.right | 7 | ||||
-rw-r--r-- | tests/array.tests | 6 | ||||
-rw-r--r-- | tests/array28.sub | 30 | ||||
-rw-r--r-- | tests/builtins.right | 38 | ||||
-rw-r--r-- | tests/builtins.tests | 3 | ||||
-rw-r--r-- | tests/builtins7.sub | 38 | ||||
-rw-r--r-- | tests/complete.right | 63 | ||||
-rw-r--r-- | tests/complete.tests | 126 | ||||
-rw-r--r-- | tests/errors.right | 5 | ||||
-rw-r--r-- | tests/errors.tests | 3 | ||||
-rw-r--r-- | tests/exp.right | 3 | ||||
-rw-r--r-- | tests/exp.tests | 2 | ||||
-rw-r--r-- | tests/history.right | 29 | ||||
-rw-r--r-- | tests/history.tests | 1 | ||||
-rw-r--r-- | tests/history4.sub | 3 | ||||
-rw-r--r-- | tests/history5.sub | 23 | ||||
-rw-r--r-- | tests/jobs.right | 33 | ||||
-rw-r--r-- | tests/jobs.tests | 2 | ||||
-rw-r--r-- | tests/jobs7.sub | 6 | ||||
-rw-r--r-- | tests/new-exp.right | 12 | ||||
-rw-r--r-- | tests/new-exp.tests | 5 | ||||
-rw-r--r-- | tests/new-exp15.sub | 29 | ||||
-rw-r--r-- | tests/run-complete | 2 | ||||
-rw-r--r-- | tests/tilde.right | 2 | ||||
-rw-r--r-- | tests/tilde.tests | 4 | ||||
-rw-r--r-- | tests/varenv.right | 5 | ||||
-rw-r--r-- | tests/varenv.tests | 1 | ||||
-rw-r--r-- | tests/varenv21.sub | 48 |
28 files changed, 507 insertions, 22 deletions
diff --git a/tests/array.right b/tests/array.right index c46ffb5e..2d1c51db 100644 --- a/tests/array.right +++ b/tests/array.right @@ -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 @@ -756,3 +757,9 @@ declare -A A=(["*"]="X" ["@"]="X" ) ./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 91f33b72..ba8e2254 100644 --- a/tests/array.tests +++ b/tests/array.tests @@ -392,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 @@ -419,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/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/builtins.right b/tests/builtins.right index 9aa182cd..832472f6 100644 --- a/tests/builtins.right +++ b/tests/builtins.right @@ -235,4 +235,40 @@ f2 () funcs unset: one-two two-two -./builtins.tests: line 279: 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 4e314416..00ebc0fd 100644 --- a/tests/builtins.tests +++ b/tests/builtins.tests @@ -275,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/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/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/errors.right b/tests/errors.right index 44dfde65..be0c8959 100644 --- a/tests/errors.right +++ b/tests/errors.right @@ -194,4 +194,7 @@ ok 4 ok 5 ./errors8.sub: line 14: set: notanoption: invalid option name ok 6 -./errors.tests: line 296: `!!': 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 7258ac6b..531b625b 100644 --- a/tests/errors.tests +++ b/tests/errors.tests @@ -288,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/exp.right b/tests/exp.right index ce417cc9..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] = <^?> diff --git a/tests/exp.tests b/tests/exp.tests index efb742f3..3e69db4f 100644 --- a/tests/exp.tests +++ b/tests/exp.tests @@ -404,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/history.right b/tests/history.right index 74eb91bc..379de48b 100644 --- a/tests/history.right +++ b/tests/history.right @@ -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 89: 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 104: fc: no command found +./history.tests: line 105: fc: no command found aa bb cc @@ -241,3 +241,26 @@ c 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 2ddd39f1..53321f05 100644 --- a/tests/history.tests +++ b/tests/history.tests @@ -86,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 diff --git a/tests/history4.sub b/tests/history4.sub index a6bfd33f..651374cf 100644 --- a/tests/history4.sub +++ b/tests/history4.sub @@ -14,6 +14,8 @@ HISTFILE=$TMPDIR/newhistory-$$ export HISTFILE +trap 'rm -f $HISTFILE' EXIT + HISTSIZE=32 HISTFILESIZE=32 echo @@ -43,4 +45,3 @@ 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 index b7cbbe1e..c44ace8a 100644 --- a/tests/history5.sub +++ b/tests/history5.sub @@ -14,7 +14,7 @@ trap 'rm -f $HISTFILE' 0 1 2 3 6 15 -HISTFILE=$TMPDIR/foohist-$$ +HISTFILE=$TMPDIR/fchist-$$ unset HISTIGNORE HISTCONTROL set -o history @@ -32,3 +32,24 @@ 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 diff --git a/tests/jobs.right b/tests/jobs.right index 283ca174..5d03b76b 100644 --- a/tests/jobs.right +++ b/tests/jobs.right @@ -32,13 +32,16 @@ i killed it 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 38: wait: %1: no such job -./jobs.tests: line 43: 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 56: wait: `1-1': not a pid or valid job spec -./jobs.tests: line 57: 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 @@ -47,7 +50,7 @@ wait-when-no-children posix jobs output [1]+ Done sleep 1 wait-for-job -./jobs.tests: line 82: wait: %2: no such job +./jobs.tests: line 84: wait: %2: no such job 127 async list wait-for-job forked @@ -60,19 +63,19 @@ sleep 2 fg-bg 4 sleep 2 fg-bg 5 -./jobs.tests: line 109: fg: %2: no such job -./jobs.tests: line 110: 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 117: fg: -s: invalid option +./jobs.tests: line 119: fg: -s: invalid option fg: usage: fg [job_spec] -./jobs.tests: line 118: bg: -s: invalid option +./jobs.tests: line 120: bg: -s: invalid option bg: usage: bg [job_spec ...] -./jobs.tests: line 123: disown: -s: invalid option +./jobs.tests: line 125: disown: -s: invalid option disown: usage: disown [-h] [-ar] [jobspec ... | pid ...] -./jobs.tests: line 127: disown: %1: no such job -./jobs.tests: line 130: 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 133: 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 & @@ -82,8 +85,8 @@ running jobs: [1] Running sleep 300 & [2]- Running sleep 350 & [3]+ Running sleep 400 & -./jobs.tests: line 150: kill: %4: no such job -./jobs.tests: line 152: 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: diff --git a/tests/jobs.tests b/tests/jobs.tests index ae9c4ee8..dacdc15d 100644 --- a/tests/jobs.tests +++ b/tests/jobs.tests @@ -31,6 +31,8 @@ ${THIS_SH} ./jobs5.sub # test out wait -f framework ${THIS_SH} ./jobs6.sub +${THIS_SH} ./jobs7.sub + jobs echo $? 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/new-exp.right b/tests/new-exp.right index d584ccd3..752bba5c 100644 --- a/tests/new-exp.right +++ b/tests/new-exp.right @@ -482,6 +482,7 @@ argv[1] = <a> argv[2] = <b> argv[1] = <> ./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> @@ -707,6 +708,17 @@ aaa bb '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] = </> diff --git a/tests/new-exp.tests b/tests/new-exp.tests index 1695128a..079426cb 100644 --- a/tests/new-exp.tests +++ b/tests/new-exp.tests @@ -563,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 ) @@ -626,6 +628,9 @@ ${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 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/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/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 48e1448d..374f3e6d 100644 --- a/tests/tilde.tests +++ b/tests/tilde.tests @@ -85,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/varenv.right b/tests/varenv.right index 90f3efc7..358f5dc7 100644 --- a/tests/varenv.right +++ b/tests/varenv.right @@ -260,6 +260,11 @@ 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 42fb54db..b058ed4f 100644 --- a/tests/varenv.tests +++ b/tests/varenv.tests @@ -258,6 +258,7 @@ ${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/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 |