In Bash, voglio annullare l'impostazione di una voce di hashmap. Ma ho fallito. Il codice è come di seguito:Bash hashmap utilizzando il preventivo come chiave
declare -A arr
arr["a'b"]=3
echo ${!arr[@]} ## output: a'b
key="a'b"
unset arr[$key] ## error: -bash: unset: `arr[a'b]': not a valid identifier
Come posso disinserire questa voce?
['unset arr [" $ key "]'] (http://mywiki.wooledge.org/BashGuide/Practices#Quoting)? ** EDIT **: Questo non funziona ... – anishsane
Sembra un bug in bash – Leon
Hmm ... mio male ... Inoltre, 'arr ['$ x'] = 123; unset arr ['$ x'] 'fornisce' -bash: unset: [$ x]: indice di array non valido ' – anishsane