diff options
author | Chet Ramey <chet.ramey@case.edu> | 2018-06-04 09:58:58 -0400 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2018-06-04 09:58:58 -0400 |
commit | 3e03eafff8ab2af82bd7576603dbde7f877d9030 (patch) | |
tree | 849042c196dd44d5a06a954ccd32fa15ac326422 /tests | |
parent | 5c5c75236c6efa6e8239c61152b8b061e3644618 (diff) | |
download | bash-3e03eafff8ab2af82bd7576603dbde7f877d9030.tar.gz |
commit bash-20180601 snapshot
Diffstat (limited to 'tests')
-rw-r--r-- | tests/histexp.right | 20 | ||||
-rw-r--r-- | tests/histexp.tests | 1 | ||||
-rw-r--r-- | tests/histexp5.sub | 28 | ||||
-rw-r--r-- | tests/posixexp.right | 8 | ||||
-rw-r--r-- | tests/posixexp.tests | 1 | ||||
-rw-r--r-- | tests/posixexp7.sub | 13 | ||||
-rw-r--r-- | tests/varenv.right | 5 | ||||
-rw-r--r-- | tests/varenv12.sub | 38 |
8 files changed, 112 insertions, 2 deletions
diff --git a/tests/histexp.right b/tests/histexp.right index bcf5dea6..11ed7330 100644 --- a/tests/histexp.right +++ b/tests/histexp.right @@ -203,3 +203,23 @@ d e ! ! ./histexp4.sub: line 20: !': event not found +/tmp/Step1 +echo /$(echo tmp)/Step1 +/tmp/Step1 +echo /<(echo tmp)/Step1 > /dev/null +/tmp/Step1 +echo $(echo /tmp)/Step1 +/tmp/Step1 +echo <(echo /tmp)/Step1 > /dev/null +/+(one|two|three)/Step1 +echo /+(one|two|three)/Step1 +/+(one|two|three)/Step1 +/*(tmp|dev|usr)/Step1 +echo /*(tmp|dev|usr)/Step1 +/*(tmp|dev|usr)/Step1 ++(/one|/two|/three)/Step1 +echo +(/one|/two|/three)/Step1 ++(/one|/two|/three)/Step1 +*(/tmp|/dev|/usr)/Step1 +echo *(/tmp|/dev|/usr)/Step1 +*(/tmp|/dev|/usr)/Step1 diff --git a/tests/histexp.tests b/tests/histexp.tests index 2901064f..22c90a76 100644 --- a/tests/histexp.tests +++ b/tests/histexp.tests @@ -140,3 +140,4 @@ ${THIS_SH} ./histexp1.sub ${THIS_SH} ./histexp2.sub ${THIS_SH} ./histexp3.sub ${THIS_SH} ./histexp4.sub +${THIS_SH} ./histexp5.sub diff --git a/tests/histexp5.sub b/tests/histexp5.sub new file mode 100644 index 00000000..0fe62fe4 --- /dev/null +++ b/tests/histexp5.sub @@ -0,0 +1,28 @@ +set -o history +set -o histexpand + +# command and process substitutions should be tokenized as a single word +echo /$(echo tmp)/Step1 +echo !:* +echo /<(echo tmp)/Step1 >/dev/null +echo !:* + +# same tests at the beginning of a word +echo $(echo /tmp)/Step1 +echo !:* +echo <(echo /tmp)/Step1 >/dev/null +echo !:* + +# so should shell extended glob patterns +shopt -s extglob + +echo /+(one|two|three)/Step1 +echo !:* +echo /*(tmp|dev|usr)/Step1 +echo !:* + +# same tests at the beginning of a word +echo +(/one|/two|/three)/Step1 +echo !:* +echo *(/tmp|/dev|/usr)/Step1 +echo !:* diff --git a/tests/posixexp.right b/tests/posixexp.right index 1e81eadb..53a08e3b 100644 --- a/tests/posixexp.right +++ b/tests/posixexp.right @@ -275,5 +275,9 @@ argv[2] = <b> [ abc def ghi jkl / abc def ghi jkl ] [ abc def ghi jkl ] [ abc def ghi jkl / abc def ghi jkl / abc def ghi jkl ] -./posixexp.tests: line 82: unexpected EOF while looking for matching `}' -./posixexp.tests: line 83: syntax error: unexpected end of file +5: notOK +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 diff --git a/tests/posixexp.tests b/tests/posixexp.tests index 76dfede9..3368711f 100644 --- a/tests/posixexp.tests +++ b/tests/posixexp.tests @@ -76,6 +76,7 @@ ${THIS_SH} ./posixexp3.sub ${THIS_SH} ./posixexp4.sub ${THIS_SH} ./posixexp5.sub ${THIS_SH} ./posixexp6.sub +${THIS_SH} ./posixexp7.sub # this will be an error foo=bar diff --git a/tests/posixexp7.sub b/tests/posixexp7.sub new file mode 100644 index 00000000..2e230cf8 --- /dev/null +++ b/tests/posixexp7.sub @@ -0,0 +1,13 @@ +# test the effect of quotes on the WORD in the posix pattern removal operators +# a here document does not behave the same as double quotes +x=notOK +cat <<EOF +5: ${x#$'not'} +EOF + +echo "${x#'not'}" +echo "${x#$'not'}" + +cat <<EOF +5: $'not\ttoo\nbad' +EOF diff --git a/tests/varenv.right b/tests/varenv.right index 7ca5f661..c9d364ff 100644 --- a/tests/varenv.right +++ b/tests/varenv.right @@ -145,8 +145,13 @@ outside: declare -x foo="abc" inside: declare -x var="value" outside: declare -- var="one" +inside: declare -x var="value" +outside: declare -x var="value" inside: declare -- var="local" outside: declare -x var="global" +foo=<unset> environment foo= +foo=foo environment foo=foo +foo=foo environment foo=foo a=z a=b a=z diff --git a/tests/varenv12.sub b/tests/varenv12.sub index 6aaf512b..edba3c94 100644 --- a/tests/varenv12.sub +++ b/tests/varenv12.sub @@ -47,6 +47,28 @@ echo -n 'outside: ' ; declare -p var unset -v var 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. + +func() +{ + local var=inside + var=value export var + echo -n 'inside: ' ; declare -p var +} + +var=outside +func +echo -n 'outside: ' ; declare -p var + +unset -v var +unset -f func + func() { local var=local @@ -60,3 +82,19 @@ 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() +{ + printf %s "foo=${foo-<unset>}" + echo -n ' environment foo=' + printenv foo || echo +} +unset foo +showfoo +foo=foo showfoo +showfoo + +unset -v foo +unset -f showfoo |