Bash-4.3 distribution sources and documentation
[platform/upstream/bash.git] / tests / array.right
1
2 ./array.tests: line 15: syntax error near unexpected token `&'
3 ./array.tests: line 15: `test=(first & second)'
4 1
5 abcde
6 abcde
7 abcde bdef
8 abcde bdef
9 declare -a BASH_ARGC='()'
10 declare -a BASH_ARGV='()'
11 declare -a BASH_LINENO='([0]="0")'
12 declare -a BASH_SOURCE='([0]="./array.tests")'
13 declare -a DIRSTACK='()'
14 declare -a FUNCNAME='([0]="main")'
15 declare -a a='([0]="abcde" [1]="" [2]="bdef")'
16 declare -a b='()'
17 declare -ar c='()'
18 abcde bdef
19 abcde bdef
20 abcde
21 abcde
22 abcde
23
24 bdef
25 hello world
26 11
27 3
28 bdef hello world test expression test 2
29 ./array.tests: line 76: readonly: `a[5]': not a valid identifier
30 declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
31 declare -ar c='()'
32 declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
33 declare -ar c='()'
34 readonly -a a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
35 readonly -a c='()'
36 a test
37 declare -a BASH_ARGC='()'
38 declare -a BASH_ARGV='()'
39 declare -a BASH_LINENO='([0]="0")'
40 declare -a BASH_SOURCE='([0]="./array.tests")'
41 declare -a DIRSTACK='()'
42 declare -a FUNCNAME='([0]="main")'
43 declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
44 declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
45 declare -ar c='()'
46 declare -a d='([1]="" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")'
47 declare -a e='([0]="test")'
48 declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
49 ./array.tests: line 100: a: readonly variable
50 ./array.tests: line 102: b[]: bad array subscript
51 ./array.tests: line 103: b[*]: bad array subscript
52 ./array.tests: line 104: ${b[   ]}: bad substitution
53 ./array.tests: line 106: c[-2]: bad array subscript
54 ./array.tests: line 107: c: bad array subscript
55
56 ./array.tests: line 109: d[7]: cannot assign list to array member
57 ./array.tests: line 111: []=abcde: bad array subscript
58 ./array.tests: line 111: [*]=last: cannot assign to non-numeric index
59 ./array.tests: line 111: [-65]=negative: bad array subscript
60 declare -a BASH_ARGC='()'
61 declare -a BASH_ARGV='()'
62 declare -a BASH_LINENO='([0]="0")'
63 declare -a BASH_SOURCE='([0]="./array.tests")'
64 declare -a DIRSTACK='()'
65 declare -a FUNCNAME='([0]="main")'
66 declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
67 declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
68 declare -ar c='()'
69 declare -a d='([1]="test test")'
70 declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
71 ./array.tests: line 119: unset: ps1: not an array variable
72 ./array.tests: line 123: declare: c: cannot destroy array variables in this way
73 this of
74 this is a test of read using arrays
75 this test
76 this is a test of arrays
77 declare -a BASH_ARGC='()'
78 declare -a BASH_ARGV='()'
79 declare -a BASH_LINENO='([0]="0")'
80 declare -a BASH_SOURCE='([0]="./array.tests")'
81 declare -a DIRSTACK='()'
82 declare -a FUNCNAME='([0]="main")'
83 declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
84 declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
85 declare -ar c='()'
86 declare -a d='([1]="test test")'
87 declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
88 declare -a rv='([0]="this" [1]="is" [2]="a" [3]="test" [4]="of" [5]="read" [6]="using" [7]="arrays")'
89 abde
90 abde
91 bbb
92 efgh
93 wxyz
94 wxyz
95 ./array.tests
96 a
97 b c
98 d
99 e f g
100 h
101 ./array.tests
102 a
103 b c
104 d
105 e f g
106 h
107 /bin /usr/bin /usr/ucb /usr/local/bin . /sbin /usr/sbin
108 bin bin ucb bin . sbin sbin
109 bin
110 / / / / / /
111 /
112 argv[1] = <bin>
113 argv[1] = </>
114 argv[1] = <sbin>
115 argv[1] = </>
116 \bin \usr/bin \usr/ucb \usr/local/bin . \sbin \usr/sbin
117 \bin \usr\bin \usr\ucb \usr\local\bin . \sbin \usr\sbin
118 \bin \usr\bin \usr\ucb \usr\local\bin . \sbin \usr\sbin
119 4 -- 4
120 7 -- 7
121 55
122 49
123 6 -- 6
124 42 14 44
125 grep [ 123 ] *
126 6 7 9
127 6 7 9 5
128 length = 3
129 value = new1 new2 new3
130 ./array.tests: line 239: narray: unbound variable
131 ./array1.sub: line 1: syntax error near unexpected token `('
132 ./array1.sub: line 1: `printf "%s\n" -a a=(a 'b  c')'
133 ./array2.sub: line 1: declare: `[]=asdf': not a valid identifier
134 ./array2.sub: line 2: a[]: bad array subscript
135 ./array2.sub: line 4: syntax error near unexpected token `('
136 ./array2.sub: line 4: `declare -a ''=(a 'b c')'
137 9
138 9
139
140
141 7 8 9
142 8 11
143 8 11
144 6
145 6
146 nordholz
147 8
148 8
149 8
150
151 a b c d e f g
152 for case if then else
153 <> < > !
154 12 14 16 18 20
155 4414758999202
156 aaa bbb
157 ./array.tests: line 289: syntax error near unexpected token `<>'
158 ./array.tests: line 289: `metas=( <> < > ! )'
159 ./array.tests: line 290: syntax error near unexpected token `<>'
160 ./array.tests: line 290: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
161 abc 3
162 case 4
163 abc case if then else 5
164 abc case if then else 5
165 0
166 case 4
167 case if then else 5
168 case if then else 5
169 argv[1] = <0>
170 argv[2] = <1>
171 argv[3] = <4>
172 argv[4] = <10>
173 argv[1] = <0>
174 argv[2] = <1>
175 argv[3] = <4>
176 argv[4] = <10>
177 argv[1] = <0>
178 argv[2] = <1>
179 argv[3] = <4>
180 argv[4] = <10>
181 argv[1] = <0 1 4 10>
182 include null element -- expect one
183 one
184 include unset element -- expect three five
185 three five
186 start at unset element -- expect five seven
187 five seven
188 too many elements -- expect three five seven
189 three five seven
190 positive offset - expect five seven
191 five seven
192 negative offset to unset element - expect seven
193 seven
194 positive offset 2 - expect seven
195 seven
196 negative offset 2 - expect seven
197 seven
198 out-of-range offset
199
200 e
201 4
202 1 4 7 10
203 'b
204 b  c
205 $0
206 t
207 [3]=abcde r s t u v
208 e
209 9
210 2
211 a b c
212 argv[1] = <-iname 'a>
213 argv[2] = <-iname 'b>
214 argv[3] = <-iname 'c>
215 'hey'
216 hey
217 ''hey
218 'hey'
219 argv[1] = <c>
220 argv[2] = <d>
221 argv[3] = <e>
222 argv[4] = <f>
223 argv[1] = <c d>
224 argv[2] = <e f>
225 argv[1] = <c d>
226 argv[2] = <e f>
227 argv[1] = <c d>
228 argv[2] = <e f>
229 argv[1] = <-iname 'abc>
230 argv[2] = <-iname 'def>
231 argv[1] = <-iname 'abc>
232 argv[2] = <-iname 'def>
233 argv[1] = <-iname>
234 argv[2] = <abc -iname def>
235 argv[1] = <-iname 'abc>
236 argv[2] = <-iname 'def>
237 argv[1] = <-iname>
238 argv[2] = <abc -iname def>
239 argv[1] = <-iname 'abc>
240 argv[2] = <-iname 'def>
241 argv[1] = <-iname 'abc>
242 argv[2] = <-iname 'def>
243 argv[1] = <-iname>
244 argv[2] = <abc -iname def>
245 *.* OK
246 1
247 a1 2 3c
248 argv[1] = <var with spaces>
249 argv[1] = <var with spaces>
250 argv[1] = <var with spacesab>
251 argv[2] = <cd>
252 argv[3] = <ef>
253 argv[1] = <var with spacesab>
254 argv[2] = <cd>
255 argv[3] = <ef>
256 argv[1] = <var with spacesab>
257 argv[2] = <cd>
258 argv[3] = <ef>
259 argv[1] = <var with spacesab>
260 argv[2] = <cd>
261 argv[3] = <ef>
262 argv[1] = <var with spacesab>
263 argv[2] = <cd>
264 argv[3] = <ef>
265 argv[1] = <var with spacesab>
266 argv[2] = <cd>
267 argv[3] = <ef>
268 2
269 argv[1] = <element1 with spaces>
270 argv[2] = <element2 with spaces>
271 argv[1] = <element1 with spaces>
272 argv[2] = <element2 with spaces>
273 nord!olz
274
275 rdholz
276
277 rdholz
278 rdho
279
280
281 argv[1] = <fooq//barq/>
282 argv[1] = <fooq>
283 argv[2] = <>
284 argv[3] = <barq>
285 argv[4] = <>
286 argv[1] = <foo!//bar!/>
287 argv[1] = <foo!>
288 argv[2] = <>
289 argv[3] = <bar!>
290 argv[4] = <>
291 argv[1] = <ooq//arq/>
292 argv[1] = <ooq>
293 argv[2] = <>
294 argv[3] = <arq>
295 argv[4] = <>
296 argv[1] = <Fooq//Barq/>
297 argv[1] = <Fooq>
298 argv[2] = <>
299 argv[3] = <Barq>
300 argv[4] = <>
301 argv[1] = <FOOQ//BARQ/>
302 argv[1] = <FOOQ>
303 argv[2] = <>
304 argv[3] = <BARQ>
305 argv[4] = <>
306 126
307 127
308 128
309 argv[1] = <\80>
310 argv[1] = <~>
311 argv[2] = <^?>
312 argv[3] = <\80>
313 argv[1] = <~>
314 argv[2] = <^?>
315 argv[3] = <\80>
316 argv[1] = <~>
317 argv[2] = <^?>
318 argv[3] = <\80>
319 Monday Tuesday Wednesday Thursday Friday Saturday Sunday
320 Monday
321 Monday
322 Tuesday
323 Monday
324 Monday
325 Tuesday
326 Monday
327 Tuesday
328 Wednesday
329 Monday
330 Tuesday
331 Wednesday
332 monday, monday, tuesday
333 wednesday, wednesday, thursday
334 monday, monday, tuesday
335 Wednesday, Wednesday, Thursday
336 nday
337 esday
338 dnesday
339 nday
340 esday
341 dnesday
342 onday
343 uesday
344 ednesday
345 onday
346 uesday
347 ednesday
348 version[agent]
349 version.agent
350 version[agent]
351 version.agent
352 version[agent] foo[bar]
353 version.agent bowl
354 foobar] foo foo[bar]
355 bleh bbb bleh
356 ab]
357 bar
358 1
359 1
360 1
361 1
362 1
363 1
364 main main
365 function function
366 function function
367 declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")'
368 declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")'
369 declare -a x='([0]="0" [1]="1" [2]="2" [4]="4")'
370 ./array14.sub: line 11: [-10]: bad array subscript
371 declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")'
372 declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="five")'
373 declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")'
374 declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5foo")'
375 declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")'
376 declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4four" [5]="5")'
377 strlen(4four) = 5
378 1 2 xx 3
379 1 2 0 3
380 1 2 xx 3
381 1 2 0 3
382 1 2 xx 3
383 foo index 1: ok
384 foo index 2: ok
385 foo: implicit reference to element 0: ok
386 foo: arithmetic evaluation: ok
387 bar: array with element zero unset: ok
388 bar: element zero: ok
389 qux: unset array: ok
390 qux: unset array element 0: ok