]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/array27.sub
bash-5.1 distribution sources and documentation
[thirdparty/bash.git] / tests / array27.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# tests for `problem' keys when using associative arrays and assoc_expand_once
15# deal with problems for now; this is a placeholder for if and when I fix them
16
17typeset -A a
18shopt -s assoc_expand_once
19
20k='['
21echo $(( a[$k]=7 ))
22
23k=']'
24echo $(( a[$k]=7 ))
25
26unset a
27
28declare -A A
29
30for k in $'\t' ' '; do
31 (( A[$k]=2 ))
32done
33declare -p A
34
35for k in ']' '*' '@'; do
36 (( A[$k]=2 ))
37done
38
39declare -p A
40
41unset A
42declare -A A
43
44for k in $'\t' ' ' ']' '*' '@'; do
45 read "A[$k]" <<< X
46done
47declare -p A
48
49unset A
50declare -A A
51
52for k in $'\t' ' ' ']' '*' '@'; do
53 printf -v "A[$k]" "%s" X
54done
55declare -p A
56
57unset A
58declare -A A
59
60for k in ']' '*' '@'; do
61 declare A[$k]=X
62done
63declare -p A
64
65unset A
66declare -A A
67
68for k in ']' '*' '@'; do
69 declare "A[$k]=X"
70done
71declare -p A
72