Oil requires the quoting of the associative array subscripts in left hand side of assignments but doesn't require it in the keys of the designated initializer. Is there rationale on this behavior? I feel it is natural not to require quoting also in assignments.
$ bin/osh -c 'declare -A d; d[a]=123'
declare -A d; d[a]=123
^~
[ -c flag ]:1: fatal: Associative array keys must be strings: $x 'x' "$x" etc.
$ bin/osh -c 'declare -A d=([a]=123)'
$
Note that Zsh also behaves differently from Bash here. Zsh accepts quoteless subscripts in assignments like Bash, but it doesn't remove "" in the subscripts in assignments.
$ zsh -c 'declare -A d; d[a]=1; declare -p d'
typeset -A d=( [a]=1 )
$ zsh -c 'declare -A d=([a]=1); declare -p d'
typeset -A d=( [a]=1 )
$ zsh -c 'declare -A d; d["a"]=1; declare -p d'
typeset -A d=( ['"a"']=1 )
$ zsh -c 'declare -A d=(["a"]=1); declare -p d'
typeset -A d=( [a]=1 )
Oil requires the quoting of the associative array subscripts in left hand side of assignments but doesn't require it in the keys of the designated initializer. Is there rationale on this behavior? I feel it is natural not to require quoting also in assignments.
Note that Zsh also behaves differently from Bash here. Zsh accepts quoteless subscripts in assignments like Bash, but it doesn't remove
""in the subscripts in assignments.