On 4/6/21 10:28 AM, Koichi Murase wrote:

Thank you for the pointer. I still think changing the syntactic
treatment of the arguments of the `unset' builtin is the cleanest way
to solve the problem of `key=@; unset -v a[$key]'. Maybe we can ask
Chet why this isn't considered.

It's not necessary, and the cost and resultant mess aren't worth it.

We now see two benefits of changing
the treatment of the arguments of `unset', 1) `unset -v a[$key]' is
not the subject to the pathname expansions and word splitting.

Appropriate quoting.

2) we
can distinguish the erasure of the element associated with key=@
`unset -v a[$key]' from the entire array erasure `unset -v a[@]'.

I'm prepared to accept the argument that it's not necessary to support
a[@] unsetting the entire array except in a compatibility mode.

Conversely, there are definitely more codes naively writing as `unset
a[1]' which can be broken by pathname expansions.

I don't think the way to fix broken code is to change the shell to
accommodate it. The bash documentation has warned about this for a long
time.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to