On Wed, Apr 14, 2021 at 6:37 AM L A Walsh <b...@tlinx.org> wrote:
>     So echo ${a[@]} = expansion of all, but
> unset a[@] would only delete 1 element w/key '@'....
> how do I echo 1 element with key '@'

Indeed we can only quote:

a['@']=1234
echo "${a['@']}"
unset "a['@']"

Or have it interpreted as a value of a variable:

key=@
a[$key]=1234
echo "${a[$key]}"
unset 'a[$key]'

The current behavior of unset already does it right because unset is
not a keyword and not a special builtin like local.  Quoting and
re-evaluation are necessary so it gets evaluated well like how it is
evaluated during expansion and assignment.

I think I finally can say I'm against unset being defaulted to the
behavior of  assoc_expand_once.  It's oversimplified, adds
inconsistencies, and will majorly break scripts.

The only change I'd want is have `unset 'a[@]'` only unset the
elements and not the array itself.

-- 
konsolebox

Reply via email to