]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/array22.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / array22.sub
CommitLineData
8868edaf
CR
1# This program is free software: you can redistribute it and/or modify
2# it under the terms of the GNU General Public License as published by
3# the Free Software Foundation, either version 3 of the License, or
4# (at your option) any later version.
5#
6# This program is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9# GNU General Public License for more details.
10#
11# You should have received a copy of the GNU General Public License
12# along with this program. If not, see <http://www.gnu.org/licenses/>.
13#
d233b485
CR
14# This isn't perfect behavior, but it establishes a baseline and will provide
15# a way to detect behavior changes
16
17echo a1
18a[0]= a[1]=; recho "${a[@]:-y}"
19unset a
20
21echo a2
22a[1]=; recho "${a[@]:-y}"
23a[1]=; recho "${a[*]:-z}"
24unset a
25
26echo a3
27a[0]= a[1]=x; recho "${a[@]:-y}"
28unset a
29
30echo a4
31a[0]= a[1]=x; recho ${a[@]:+y}
32unset a
33
34echo p1
35set '' ''
36recho "${@:-y}"
37
38shift $#
39
40echo p2
41set '' x
42recho "${@:-y}"
43
44shift $#
45
46echo p3
47set '' x
48recho ${@:+y}
49
50# problems with * and null expansions dating back to bash's earliest days
51A=(''); set -- ''
52
53echo "<${A[*]:-X}>" "<${*:-X}>" "<${A:-X}>" "<${A[0]:-X}>"
54
55IFS=
56A=('' ''); set -- '' ''
57B=''
58
59echo "<${A[*]:-X}>" "<${*:-X}>" "<${B:-X}>" "<${B[*]:-X}>"