diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:33:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:33:23 +0000 |
commit | 1d5cace9db9aef76f26b2d7ba54bbb76443b00b2 (patch) | |
tree | 314a15dd1aa103da13bdc83ba1d2105a290bc5ba /tests/assoc.right | |
parent | Initial commit. (diff) | |
download | bash-upstream/5.0.tar.xz bash-upstream/5.0.zip |
Adding upstream version 5.0.upstream/5.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/assoc.right | 231 |
1 files changed, 231 insertions, 0 deletions
diff --git a/tests/assoc.right b/tests/assoc.right new file mode 100644 index 0000000..90abb6d --- /dev/null +++ b/tests/assoc.right @@ -0,0 +1,231 @@ +declare -A BASH_ALIASES=() +declare -A BASH_CMDS=() +declare -A fluff +declare -A BASH_ALIASES=() +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 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 -A chaff=(["hello world"]="flip" [one]="a" ) +flip +argv[1] = <multiple> +argv[2] = <words> +argv[3] = <flip> +argv[4] = <a> +argv[1] = <multiple words> +argv[2] = <flip> +argv[3] = <a> +argv[1] = <multiple> +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" ) +argv[1] = <qux> +argv[2] = <qix> +argv[1] = <qux qix> +declare -A wheat=(["foo bar"]="qux qix" [six]="6" ) +argv[1] = <2> +argv[1] = <7> +argv[1] = <qux> +argv[2] = <qix> +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> +8 +/sbin /usr/bin /bin /usr/ucb /usr/local/bin . /usr/sbin /bin +sbin bin bin ucb bin . sbin bin +bin +/ / / / / / / +/ +argv[1] = <bin> +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 +/ / / / / / / +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 +([a]=1) + +foo qux +/usr/sbin/foo /usr/local/bin/qux +hits command + 0 /sbin/blat + 0 /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 + +foo qux +argv[1] = </usr/sbin/foo> +argv[2] = </usr/local/bin/qux> +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 foo sh qux +argv[1] = <cd /blat ; echo $PWD> +argv[2] = </usr/sbin/foo> +argv[3] = </bin/bash --login -o posix> +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" ) +argv[1] = <inside:> +argv[2] = <foo quux> +argv[3] = <six> +outside 2: outside +argv[1] = </barq//fooq> +argv[1] = <> +argv[2] = <barq> +argv[3] = <> +argv[4] = <fooq> +argv[1] = </bar!//foo!> +argv[1] = <> +argv[2] = <bar!> +argv[3] = <> +argv[4] = <foo!> +argv[1] = </arq//ooq> +argv[1] = <> +argv[2] = <arq> +argv[3] = <> +argv[4] = <ooq> +argv[1] = </Barq//Fooq> +argv[1] = <> +argv[2] = <Barq> +argv[3] = <> +argv[4] = <Fooq> +argv[1] = </BARQ//FOOQ> +argv[1] = <> +argv[2] = <BARQ> +argv[3] = <> +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" ) + +123 +myarray=([foo]="bleh" ["]"]="def" ["a]=test2;#a"]="def" ["a]=test1;#a"]="123" ["a]a"]="abc" ) +bar"bie +doll +declare -A foo=(["bar\"bie"]="doll" ) +bar"bie +doll +declare -A foo=(["bar\"bie"]="doll" ) +bar"bie +doll +declare -A foo=(["bar\"bie"]="doll" ) +bar"bie +doll +declare -A foo=(["bar\"bie"]="doll" ) +bar"bie +doll +declare -A foo=(["bar\"bie"]="doll" ) +bar'bie +doll +declare -A foo=(["bar'bie"]="doll" ) +bar'bie +doll +declare -A foo=(["bar'bie"]="doll" ) +bar'bie +doll +declare -A foo=(["bar'bie"]="doll" ) +bar'bie +doll +declare -A foo=(["bar'bie"]="doll" ) +bar'bie +doll +declare -A foo=(["bar'bie"]="doll" ) +bar$bie +doll +declare -A foo=(["bar\$bie"]="doll" ) +bar[bie +doll +declare -A foo=(["bar[bie"]="doll" ) +bar`bie +doll +declare -A foo=(["bar\`bie"]="doll" ) +bar\]bie +doll +declare -A foo=(["bar\\]bie"]="doll" ) +bar${foo}bie +doll +declare -A foo=(["bar\${foo}bie"]="doll" ) +bar +after printf +after use: 0 +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 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=(["'"]="3" ["\""]="1" ["\\"]="4" ["\`"]="2" ) +declare -A dict=(["'"]="3" ["\""]="1" ["\\"]="4" ["\`"]="2" ) +declare -A dict=() +4 +4 +a[$b]= 5 +declare -A a=(["80's"]="Depeche Mode" ) +./assoc9.sub: line 71: 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 +declare -A a +declare -A a=(["80's"]="Depeche Mode" ) +6 +1 +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 +f: declare -a a +./assoc10.sub: line 4: 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" |