blob: ca3c72223ba85094c4462546f14e3a4e90acde86 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
GNU `bash`
==========
(Associative) arrays
--------------------
### Expansion
Yes:
func ${arr[@]+"${arr[@]}"}
No:
func "${arr[@]}" # doesn't work with `nounset`
func "${arr[@]+"${arr[@]}"}" # doesn't work with ('')
### `unset`
Yes:
unset -v 'arr[$i]'
No:
unset -v arr[x] # globbing
unset -v arr[$i] # the same problem + quoting
unset -v 'arr["x"]' # doesn't work for some reason
unset -v 'arr["]"]' # the same as above; just to highlight the problem with funny characters in array indices
# insightful discussion: https://lists.gnu.org/archive/html/help-bash/2016-09/msg00020.html
|