From f250956cb2a8dca13fc0242affc225f9d6983604 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Thu, 20 Dec 2018 11:41:58 -0500 Subject: bash-5.0-rc1 release --- tests/array.right | 88 +++++++++++++-------------- tests/assoc.right | 170 ++++++++++++++++++++++++++-------------------------- tests/casemod.right | 8 +-- tests/exp.right | 8 ++- tests/exp7.sub | 12 ++++ tests/new-exp.right | 26 ++++---- tests/new-exp.tests | 4 ++ tests/varenv.right | 4 +- tests/version | 5 ++ tests/version.mini | 5 ++ 10 files changed, 180 insertions(+), 150 deletions(-) (limited to 'tests') diff --git a/tests/array.right b/tests/array.right index ff0c3dd2..3986ac86 100644 --- a/tests/array.right +++ b/tests/array.right @@ -446,7 +446,7 @@ declare -a a=([0]="1" [1]="2" [2]="3") declare -A a=() declare -- a="([0]=a [1]=b)" declare -a 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]") @@ -614,19 +614,19 @@ reference: 5. 6. assignment: -1.declare -A a=([" "]="10" [0]="0" [1]="1" ) -2.declare -A a=([" "]="11" [0]="0" [1]="1" ) -3.declare -A a=([" "]="12" [0]="0" [1]="1" ) -4.declare -A a=([" "]="13" [0]="0" [1]="1" ) +1.declare -A a=([1]="1" [0]="0" [" "]="10" ) +2.declare -A a=([1]="1" [0]="0" [" "]="11" ) +3.declare -A a=([1]="1" [0]="0" [" "]="12" ) +4.declare -A a=([1]="1" [0]="0" [" "]="13" ) arithmetic: -1.declare -A a=([" "]="10" [0]="0" [1]="1" ) -2.declare -A a=([" "]="11" [0]="0" [1]="1" ) -3.declare -A a=([" "]="12" [0]="0" [1]="1" ) -4.declare -A a=([" "]="13" [0]="0" [1]="1" ) -5.declare -A a=([" "]="10" [0]="0" [1]="1" ) -6.declare -A a=([" "]="10" [0]="0" [1]="1" ["\" \""]="11" ) -7.declare -A a=([" "]="12" [0]="0" [1]="1" ["\" \""]="11" ) -8.declare -A a=([" "]="12" [0]="0" [1]="1" ["\" \""]="13" ) +1.declare -A a=([1]="1" [0]="0" [" "]="10" ) +2.declare -A a=([1]="1" [0]="0" [" "]="11" ) +3.declare -A a=([1]="1" [0]="0" [" "]="12" ) +4.declare -A a=([1]="1" [0]="0" [" "]="13" ) +5.declare -A a=([1]="1" [0]="0" [" "]="10" ) +6.declare -A a=([1]="1" [0]="0" [" "]="10" ["\" \""]="11" ) +7.declare -A a=([1]="1" [0]="0" [" "]="12" ["\" \""]="11" ) +8.declare -A a=([1]="1" [0]="0" [" "]="12" ["\" \""]="13" ) argv[1] = argv[2] = argv[1] = @@ -665,13 +665,13 @@ argv[1] = argv[1] = argv[1] = argv[2] = -argv[1] = -argv[2] = -argv[1] = -argv[2] = -argv[1] = -argv[2] = -argv[1] = +argv[1] = +argv[2] = +argv[1] = +argv[2] = +argv[1] = +argv[2] = +argv[1] = argv[1] = argv[2] = argv[1] = @@ -688,13 +688,13 @@ argv[1] = argv[1] = argv[1] = argv[2] = -argv[1] = -argv[2] = -argv[1] = -argv[2] = -argv[1] = -argv[2] = -argv[1] = +argv[1] = +argv[2] = +argv[1] = +argv[2] = +argv[1] = +argv[2] = +argv[1] = argv[1] = argv[2] = argv[1] = @@ -719,13 +719,13 @@ argv[1] = argv[2] = argv[3] = argv[4] = -argv[1] = -argv[2] = -argv[1] = -argv[2] = -argv[1] = -argv[2] = -argv[1] = +argv[1] = +argv[2] = +argv[1] = +argv[2] = +argv[1] = +argv[2] = +argv[1] = argv[1] = argv[2] = argv[1] = @@ -740,22 +740,22 @@ argv[1] = argv[2] = argv[3] = argv[4] = -argv[1] = -argv[2] = -argv[1] = -argv[2] = -argv[1] = -argv[2] = -argv[1] = +argv[1] = +argv[2] = +argv[1] = +argv[2] = +argv[1] = +argv[2] = +argv[1] = 7 ./array27.sub: line 11: 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 ") -declare -A A=([$'\t']="2" [" "]="2" ["*"]="2" ["@"]="2" ) +declare -A A=([$'\t']="2" ["*"]="2" [" "]="2" ["@"]="2" ) ./array27.sub: line 32: A[]]: bad array subscript -declare -A A=([$'\t']="X" [" "]="X" ["*"]="X" ["@"]="X" ) +declare -A A=([$'\t']="X" ["*"]="X" [" "]="X" ["@"]="X" ) ./array27.sub: line 40: A[]]: bad array subscript -declare -A A=([$'\t']="X" [" "]="X" ["*"]="X" ["@"]="X" ) +declare -A A=([$'\t']="X" ["*"]="X" [" "]="X" ["@"]="X" ) ./array27.sub: line 48: declare: `A[]]=X': not a valid identifier declare -A A=(["*"]="X" ["@"]="X" ) ./array27.sub: line 56: declare: `A[]]=X': not a valid identifier diff --git a/tests/assoc.right b/tests/assoc.right index 99143f00..90abb6d6 100644 --- a/tests/assoc.right +++ b/tests/assoc.right @@ -3,43 +3,43 @@ declare -A BASH_CMDS=() declare -A fluff declare -A BASH_ALIASES=() declare -A BASH_CMDS=() -declare -A fluff=([bar]="two" [foo]="one" ) -declare -A fluff=([bar]="two" [foo]="one" ) +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 BASH_ALIASES=() declare -A BASH_CMDS=() -declare -Ai chaff=([one]="10" [zero]="5" ) -declare -Ar waste=([version]="4.0-devel" [source]="./assoc.tests" [lineno]="28" [pid]="42134" ) -declare -A wheat=([two]="b" [three]="c" [one]="a" [zero]="0" ) -declare -A chaff=([one]="10" ["hello world"]="flip" [zero]="5" ) +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 -A chaff=([one]="a" ["hello world"]="flip" ) +declare -A chaff=(["hello world"]="flip" [one]="a" ) flip -argv[1] = +argv[1] = +argv[2] = +argv[3] = +argv[4] = +argv[1] = argv[2] = -argv[3] = -argv[4] = -argv[1] = -argv[2] = -argv[3] = -argv[1] = -argv[2] = -argv[3] = -argv[4] = -argv[1] = +argv[3] = +argv[1] = +argv[2] = +argv[3] = +argv[4] = +argv[1] = ./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=([six]="6" ["foo bar"]="qux qix" ) +declare -A wheat=(["foo bar"]="qux qix" [six]="6" ) argv[1] = argv[2] = argv[1] = -declare -A wheat=([six]="6" ["foo bar"]="qux qix" ) +declare -A wheat=(["foo bar"]="qux qix" [six]="6" ) argv[1] = <2> argv[1] = <7> argv[1] = @@ -48,16 +48,16 @@ argv[3] = argv[1] = argv[1] = <16> argv[1] = <16> -argv[1] = <6> -argv[2] = -argv[1] = -argv[2] = -argv[3] = -argv[1] = -argv[2] = +argv[1] = +argv[2] = <6> +argv[1] = +argv[2] = +argv[3] = +argv[1] = +argv[2] = 8 -. /sbin /usr/bin /bin /usr/ucb /usr/local/bin /bin /usr/sbin -. sbin bin bin ucb bin bin sbin +/sbin /usr/bin /bin /usr/ucb /usr/local/bin . /usr/sbin /bin +sbin bin bin ucb bin . sbin bin bin / / / / / / / / @@ -66,83 +66,83 @@ argv[1] = argv[1] = argv[1] = 8 -. /sbin /usr/bin /bin /usr/ucb /usr/local/bin /bin /usr/sbin -. sbin bin bin ucb bin bin sbin +/sbin /usr/bin /bin /usr/ucb /usr/local/bin . /usr/sbin /bin +sbin bin bin ucb bin . sbin bin / / / / / / / 8 4 -- /bin -. ^sbin ^usr^bin ^bin ^usr^ucb ^usr^local^bin ^bin ^usr^sbin -. ^sbin ^usr^bin ^bin ^usr^ucb ^usr^local^bin ^bin ^usr^sbin -. \sbin \usr/bin \bin \usr/ucb \usr/local/bin \bin \usr/sbin -. \sbin \usr\bin \bin \usr\ucb \usr\local\bin \bin \usr\sbin -. \sbin \usr\bin \bin \usr\ucb \usr\local\bin \bin \usr\sbin +^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 ([a]=1) -qux foo -/usr/local/bin/qux /usr/sbin/foo +foo qux +/usr/sbin/foo /usr/local/bin/qux hits command 0 /sbin/blat - 0 /usr/local/bin/qux - 0 /bin/sh 0 /usr/sbin/foo -blat qux sh foo -/sbin/blat /usr/local/bin/qux /bin/sh /usr/sbin/foo + 0 /bin/sh + 0 /usr/local/bin/qux +blat foo sh qux +/sbin/blat /usr/sbin/foo /bin/sh /usr/local/bin/qux -qux foo -argv[1] = -argv[2] = <-l> -argv[3] = +foo qux +argv[1] = +argv[2] = +argv[3] = <-l> alias blat='cd /blat ; echo $PWD' alias foo='/usr/sbin/foo' alias qux='/usr/local/bin/qux -l' alias sh='/bin/bash --login -o posix' -blat qux sh foo +blat foo sh qux argv[1] = -argv[2] = +argv[2] = argv[3] = -argv[4] = +argv[4] = outside: outside declare -A BASH_ALIASES=() declare -A BASH_CMDS=() -declare -A afoo=([six]="six" ["foo bar"]="foo quux" ) +declare -A afoo=(["foo bar"]="foo quux" [six]="six" ) argv[1] = -argv[2] = -argv[3] = +argv[2] = +argv[3] = outside 2: outside -argv[1] = -argv[1] = -argv[2] = <> -argv[3] = -argv[4] = <> -argv[1] = -argv[1] = -argv[2] = <> -argv[3] = -argv[4] = <> -argv[1] = -argv[1] = -argv[2] = <> -argv[3] = -argv[4] = <> -argv[1] = -argv[1] = -argv[2] = <> -argv[3] = -argv[4] = <> -argv[1] = -argv[1] = -argv[2] = <> -argv[3] = -argv[4] = <> +argv[1] = +argv[1] = <> +argv[2] = +argv[3] = <> +argv[4] = +argv[1] = +argv[1] = <> +argv[2] = +argv[3] = <> +argv[4] = +argv[1] = +argv[1] = <> +argv[2] = +argv[3] = <> +argv[4] = +argv[1] = +argv[1] = <> +argv[2] = +argv[3] = <> +argv[4] = +argv[1] = +argv[1] = <> +argv[2] = +argv[3] = <> +argv[4] = abc def def ./assoc5.sub: line 13: declare: `myarray[foo[bar]=bleh': not a valid identifier -bleh abc def -myarray=(["a]=test1;#a"]="123" [foo]="bleh" ["a]a"]="abc" ["]"]="def" ) +bleh def abc +myarray=([foo]="bleh" ["]"]="def" ["a]=test1;#a"]="123" ["a]a"]="abc" ) 123 -myarray=(["a]=test1;#a"]="123" [foo]="bleh" ["a]a"]="abc" ["a]=test2;#a"]="def" ["]"]="def" ) +myarray=([foo]="bleh" ["]"]="def" ["a]=test2;#a"]="def" ["a]=test1;#a"]="123" ["a]a"]="abc" ) bar"bie doll declare -A foo=(["bar\"bie"]="doll" ) @@ -195,15 +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 b=(["\""]="" [")"]="" ["\\"]="" ["]"]="" ["\`"]="" ) +declare -A b=([")"]="" ["\""]="" ["]"]="" ["\\"]="" ["\`"]="" ) declare -A b=(["]"]="" ["\`"]="" ) -declare -A dict=(["\""]="1" ["'"]="3" ["\\"]="4" ["\`"]="2" ) -./assoc9.sub: line 23: unset: `dict["]': not a valid identifier +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 -declare -A dict=(["\""]="1" ["'"]="3" ["\\"]="4" ["\`"]="2" ) -declare -A dict=(["\""]="1" ["'"]="3" ["\\"]="4" ["\`"]="2" ) +declare -A dict=(["'"]="3" ["\""]="1" ["\\"]="4" ["\`"]="2" ) +declare -A dict=(["'"]="3" ["\""]="1" ["\\"]="4" ["\`"]="2" ) declare -A dict=() 4 4 diff --git a/tests/casemod.right b/tests/casemod.right index ca1de49a..a5840171 100644 --- a/tests/casemod.right +++ b/tests/casemod.right @@ -13,10 +13,10 @@ aCKNOWLEDGEMENT oENOPHILE aCKNoWLeDGeMeNT oeNoPHiLe aCKNOWLEDGEMENT oENOPHILE acknowledgement oenophile -Acknowledgement Oenophile -ACKNOWLEDGEMENT OENOPHILE -Acknowledgement Oenophile -AcknOwlEdgEmEnt OEnOphIlE +Oenophile Acknowledgement +OENOPHILE ACKNOWLEDGEMENT +Oenophile Acknowledgement +OEnOphIlE AcknOwlEdgEmEnt oENOPHILE aCKNOWLEDGEMENT oenophile acknowledgement oENOPHILE aCKNOWLEDGEMENT diff --git a/tests/exp.right b/tests/exp.right index 599482a7..a2dc86f9 100644 --- a/tests/exp.right +++ b/tests/exp.right @@ -210,14 +210,18 @@ argv[1] = argv[2] = argv[1] = argv[2] = -./exp7.sub: line 5: INFORM: dequote_string: string with bare CTLESC argv[1] = <^A> argv[1] = <3> argv[2] = <^C> argv[3] = <^C> argv[4] = <^C> -./exp7.sub: line 10: INFORM: dequote_string: string with bare CTLESC argv[1] = <^A> +argv[1] = +argv[2] = +argv[1] = +argv[1] = +argv[2] = +argv[1] = argv[1] = argv[1] = declare -- var="xyz" diff --git a/tests/exp7.sub b/tests/exp7.sub index 0a4acc3c..f3f3b6bd 100644 --- a/tests/exp7.sub +++ b/tests/exp7.sub @@ -9,3 +9,15 @@ recho $# "$1" "$2" "$3" x=$c recho "$x" + +unset c c2 x + +c=$'Y\1Y'; + +v=X${c}X; +recho X${c}X +recho "$v" + +v=X$c +recho X$c +recho "$v" diff --git a/tests/new-exp.right b/tests/new-exp.right index b2337bd8..c0f78fbb 100644 --- a/tests/new-exp.right +++ b/tests/new-exp.right @@ -3,7 +3,7 @@ argv[1] = argv[1] = argv[1] = argv[1] = -./new-exp.tests: line 24: HOME: }: syntax error: operand expected (error token is "}") +./new-exp.tests: line 28: HOME: }: syntax error: operand expected (error token is "}") unset argv[1] = argv[1] = @@ -66,8 +66,8 @@ argv[4] = argv[1] = argv[2] = argv[3] = -./new-exp.tests: line 180: ABX: unbound variable -./new-exp.tests: line 184: $6: cannot assign in this way +./new-exp.tests: line 184: ABX: unbound variable +./new-exp.tests: line 188: $6: cannot assign in this way argv[1] = argv[1] = argv[1] = @@ -176,7 +176,7 @@ a ./new-exp2.sub: line 49: 1111111111111111111111: command not found argv[1] = <6> -./new-exp.tests: line 285: ${#:}: bad substitution +./new-exp.tests: line 289: ${#:}: bad substitution argv[1] = <'> argv[1] = <"> argv[1] = <"hello"> @@ -411,13 +411,13 @@ argv[6] = argv[7] = argv[8] = argv[9] = -./new-exp.tests: line 503: $9: unbound variable -./new-exp.tests: line 504: 9: unbound variable -./new-exp.tests: line 505: UNSET: unbound variable -./new-exp.tests: line 506: UNSET: unbound variable -./new-exp.tests: line 507: UNSET: unbound variable -./new-exp.tests: line 508: UNSET: unbound variable +./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 argv[1] = <5> argv[1] = <#> argv[1] = <#> @@ -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 529: ${$(($#-1))}: bad substitution +./new-exp.tests: line 533: ${$(($#-1))}: bad substitution argv[1] = argv[2] = argv[3] = @@ -481,7 +481,7 @@ argv[1] = argv[1] = argv[2] = argv[1] = <> -./new-exp.tests: line 548: $(($# - 2)): substring expression < 0 +./new-exp.tests: line 552: $(($# - 2)): substring expression < 0 argv[1] = argv[2] = argv[3] = @@ -669,4 +669,4 @@ prependÃ¥ ḅć argv[1] = argv[1] = -./new-exp.tests: line 611: ABXD: parameter unset +./new-exp.tests: line 615: ABXD: parameter unset diff --git a/tests/new-exp.tests b/tests/new-exp.tests index 31e15468..557d6b44 100644 --- a/tests/new-exp.tests +++ b/tests/new-exp.tests @@ -1,3 +1,7 @@ +if (( $UID == 0 )); then + echo "new-exp.tests: the test suite should not be run as root" >&2 +fi + # must do this because posix mode causes process substitution to be disabled # and flagged as a syntax error, which causes the shell to exit set +o posix diff --git a/tests/varenv.right b/tests/varenv.right index 4e8c0d16..159a8773 100644 --- a/tests/varenv.right +++ b/tests/varenv.right @@ -130,9 +130,9 @@ func: null or unset after func: x = outside ./varenv11.sub: line 4: local: qux: readonly variable ./varenv11.sub: line 5: qux: readonly variable -declare -A foo=([one]="one" [zero]="zero" ) +declare -A foo=([zero]="zero" [one]="one" ) declare -a bar=([0]="zero" [1]="one") -declare -A foo=([one]="one" [zero]="zero" ) +declare -A foo=([zero]="zero" [one]="one" ) declare -a bar=([0]="zero" [1]="one") ./varenv11.sub: line 29: a: readonly variable foo=abc diff --git a/tests/version b/tests/version index bd740205..9ad08f7d 100644 --- a/tests/version +++ b/tests/version @@ -1,3 +1,8 @@ +if (( $UID == 0 )); then + echo "${THIS_SH}: the test suite should not be run as root" >&2 + echo +fi + echo Testing ${THIS_SH} echo version: $BASH_VERSION diff --git a/tests/version.mini b/tests/version.mini index 72e4bf96..637565ea 100644 --- a/tests/version.mini +++ b/tests/version.mini @@ -1,3 +1,8 @@ +if (( $UID == 0 )); then + echo "${THIS_SH}: the test suite should not be run as root" >&2 + echo +fi + echo Testing ${THIS_SH} echo version: $BASH_VERSION -- cgit v1.2.1