1 declare -A BUSH_ALIASES=()
2 declare -A BUSH_CMDS=()
4 declare -A BUSH_ALIASES=()
5 declare -A BUSH_CMDS=()
6 declare -A fluff=([foo]="one" [bar]="two" )
7 declare -A fluff=([foo]="one" [bar]="two" )
8 declare -A fluff=([bar]="two" )
9 declare -A fluff=([qux]="assigned" [bar]="newval" )
10 ./assoc.tests: line 39: chaff: four: must use subscript when assigning associative array
11 declare -A BUSH_ALIASES=()
12 declare -A BUSH_CMDS=()
13 declare -Ai chaff=([one]="10" [zero]="5" )
14 declare -Ar waste=([pid]="42134" [lineno]="41" [source]="./assoc.tests" [version]="4.0-devel" )
15 declare -A wheat=([two]="b" [three]="c" [one]="a" [zero]="0" )
16 declare -A chaff=(["hello world"]="flip" [one]="10" [zero]="5" )
17 ./assoc.tests: line 51: waste: readonly variable
18 ./assoc.tests: line 52: unset: waste: cannot unset: readonly variable
19 ./assoc.tests: line 53: chaff[*]: bad array subscript
20 ./assoc.tests: line 54: [*]=12: invalid associative array key
21 declare -A chaff=(["hello world"]="flip" [one]="a" )
27 argv[1] = <multiple words>
34 argv[1] = <multiple words flip a>
35 ./assoc.tests: line 71: declare: chaff: cannot destroy array variables in this way
36 ./assoc.tests: line 73: chaff[*]: bad array subscript
37 ./assoc.tests: line 74: [*]=12: invalid associative array key
38 declare -A wheat=([six]="6" ["foo bar"]="qux qix" )
42 declare -A wheat=([six]="6" ["foo bar"]="qux qix" )
48 argv[1] = <qux qix blat>
59 /usr/local/bin /bin . /usr/bin /usr/ucb /usr/sbin /bin /sbin
60 bin bin . bin ucb sbin bin sbin
69 /usr/local/bin /bin . /usr/bin /usr/ucb /usr/sbin /bin /sbin
70 bin bin . bin ucb sbin bin sbin
74 ^usr^local^bin ^bin . ^usr^bin ^usr^ucb ^usr^sbin ^bin ^sbin
75 ^usr^local^bin ^bin . ^usr^bin ^usr^ucb ^usr^sbin ^bin ^sbin
76 \usr/local/bin \bin . \usr/bin \usr/ucb \usr/sbin \bin \sbin
77 \usr\local\bin \bin . \usr\bin \usr\ucb \usr\sbin \bin \sbin
78 \usr\local\bin \bin . \usr\bin \usr\ucb \usr\sbin \bin \sbin
82 /usr/sbin/foo /usr/local/bin/qux
89 /usr/sbin/foo /bin/sh /sbin/blat /usr/local/bin/qux
92 argv[1] = </usr/sbin/foo>
93 argv[2] = </usr/local/bin/qux>
95 alias blat='cd /blat ; echo $PWD'
96 alias foo='/usr/sbin/foo'
97 alias qux='/usr/local/bin/qux -l'
98 alias sh='/bin/bush --login -o posix'
100 argv[1] = <cd /blat ; echo $PWD>
101 argv[2] = </usr/sbin/foo>
102 argv[3] = </bin/bush --login -o posix>
103 argv[4] = </usr/local/bin/qux -l>
105 declare -A BUSH_ALIASES=()
106 declare -A BUSH_CMDS=()
107 declare -A afoo=([six]="six" ["foo bar"]="foo quux" )
112 argv[1] = </barq//fooq>
117 argv[1] = </bar!//foo!>
122 argv[1] = </arq//ooq>
127 argv[1] = </Barq//Fooq>
132 argv[1] = </BARQ//FOOQ>
140 ./assoc5.sub: line 26: declare: `myarray[foo[bar]=bleh': not a valid identifier
142 myarray=(["]"]="def" [foo]="bleh" ["a]a"]="abc" ["a]=test1;#a"]="123" )
145 myarray=(["]"]="def" ["a]=test2;#a"]="def" [foo]="bleh" ["a]a"]="abc" ["a]=test1;#a"]="123" )
148 declare -A foo=(["bar\"bie"]="doll" )
151 declare -A foo=(["bar\"bie"]="doll" )
154 declare -A foo=(["bar\"bie"]="doll" )
157 declare -A foo=(["bar\"bie"]="doll" )
160 declare -A foo=(["bar\"bie"]="doll" )
163 declare -A foo=(["bar'bie"]="doll" )
166 declare -A foo=(["bar'bie"]="doll" )
169 declare -A foo=(["bar'bie"]="doll" )
172 declare -A foo=(["bar'bie"]="doll" )
175 declare -A foo=(["bar'bie"]="doll" )
178 declare -A foo=(["bar\$bie"]="doll" )
181 declare -A foo=(["bar[bie"]="doll" )
184 declare -A foo=(["bar\`bie"]="doll" )
187 declare -A foo=(["bar\\]bie"]="doll" )
190 declare -A foo=(["bar\${foo}bie"]="doll" )
194 declare -A assoc=([0]="assoc" )
196 declare -A assoc=([two]="twoless" [three]="three" [one]="onemore" )
197 declare -Ar assoc=([two]="twoless" [three]="three" [one]="onemore" )
198 declare -A hash=([key]="value1" )
199 declare -A hash=([key]="value1 value2" )
200 declare -A b=([")"]="" ["\""]="" ["]"]="" ["\\"]="" ["\`"]="" )
201 declare -A b=(["]"]="" ["\`"]="" )
202 declare -A dict=(["'"]="3" ["\""]="1" ["\\"]="4" ["\`"]="2" )
203 ./assoc9.sub: line 36: unset: `dict[']': not a valid identifier
204 ./assoc9.sub: line 36: unset: `dict["]': not a valid identifier
205 ./assoc9.sub: line 36: unset: `dict[\]': not a valid identifier
206 ./assoc9.sub: line 36: unset: `dict[`]': not a valid identifier
207 declare -A dict=(["'"]="3" ["\""]="1" ["\\"]="4" ["\`"]="2" )
208 declare -A dict=(["'"]="3" ["\""]="1" ["\\"]="4" ["\`"]="2" )
213 declare -A a=(["80's"]="Depeche Mode" )
214 ./assoc9.sub: line 84: read: `a[80's]': not a valid identifier
216 declare -A a=(["80's"]="Depeche Mode" )
217 ./assoc9.sub: line 96: printf: `a[80's]': not a valid identifier
219 declare -A a=(["80's"]="Depeche Mode" )
223 declare -A a=(["\$(date >&2)"]="5" )
224 declare -A myarray=([foo]="bleh" ["foo[bar"]="bleh" )
226 ./assoc10.sub: line 14: declare: a: cannot convert indexed to associative array
228 ./assoc10.sub: line 17: declare: a: cannot convert associative to indexed array
232 main: declare -- a="7"
234 main: declare -- a="42"
235 declare -A a=([3]="" [1]="2" )
236 declare -A foo=([d]="4" [c]="3" [b]="2" [a]="1" )
237 foo=( d "4" c "3" b "2" a "1" )
238 declare -A foo=(["\\"]="5" ["@"]="3" ["holy hell this works"]="4" ["a b"]="1" ["spa ces"]="2" )
239 foo=( echo "\\" "5" "@" "3" "holy hell this works" "4" "a b" "1" "spa ces" "2" )
240 ./assoc11.sub: line 34: "": bad array subscript
241 declare -A foo=([";"]="semicolon" ["]"]="def" [a=b]="assignment" ["a]a"]="abc" ["foo[bar"]="bleh" )
242 foo=( ";" "semicolon" "]" "def" a=b "assignment" "a]a" "abc" "foo[bar" "bleh" )
243 declare -A foo=(["'"]="squote" ["\""]="dquote" ["\\"]="bslash" ["\`"]="backquote" )
244 foo=( "'" "squote" "\"" "dquote" "\\" "bslash" "\`" "backquote" )
245 declare -A foo=(["bar]bie"]="doll" ["a]=test1;#a"]="123" ["bar\"bie"]="doll" )
246 foo=( "bar]bie" "doll" "a]=test1;#a" "123" "bar\"bie" "doll" )
247 declare -A inside=([c]="3" [b]="2" [a]="1" )
248 inside=( c "3" b "2" a "1" )
249 declare -A dict=(["?"]="quest" ["*"]="star" ["'"]="squote" ["\$"]="dol" ["\""]="dquote" ["\\"]="bslash" ["@"]="at" ["}"]="rbrace" ["{"]="lbrace" ["\`"]="bquote" )
250 dict=( "?" "quest" "*" "star" "'" "squote" "\$" "dol" "\"" "dquote" "\\" "bslash" "@" "at" "}" "rbrace" "{" "lbrace" "\`" "bquote" )
251 declare -A foo=([two]="" [one]="1" )
252 foo=( two "" one "1" )
253 rparen dquote rbrace bs
254 declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
255 ")" "rparen" "\"" "dquote" "]" "rbrace" "\\" "bs"
256 declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
257 declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
258 declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
259 declare -Arx foo=([two]="2" [three]="3" [one]="1" )
260 ./assoc11.sub: line 90: foo: readonly variable