Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[doogie@xxxxxxxxxx: Bug#163391: unset array[key] where key is non-existent doesn't fail]
- X-seq: zsh-workers 17773
- From: Clint Adams <clint@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: [doogie@xxxxxxxxxx: Bug#163391: unset array[key] where key is non-existent doesn't fail]
- Date: Sat, 5 Oct 2002 13:31:25 -0400
- Cc: 163391-forwarded@xxxxxxxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
I'm not sure to what "contract" he's referring, but SUSv3 says
Unsetting a variable or function that was not previously set shall not
be considered an error and does not cause the shell to abort.
and that unset should return a >0 exit status if any of the "name"
operands cannot be unset.
Of course, it knows nothing about associative arrays.
----- Forwarded message from Adam Heath <doogie@xxxxxxxxxx> -----
bash-2.05b$ zsh -c 'unset non_existant_var && echo error || echo
correct; unset "array[1]" && echo error || echo correct; declare -A
aarray; unset "aarray[foo]" && echo error || echo correct'
correct
correct
error
The contract for unset says that if the variable being unset doesn't exist, an
error is returned. As shown above, variables and normal arrays behave as
expected, but associative arrays do not.
----- End forwarded message -----
Messages sorted by:
Reverse Date,
Date,
Thread,
Author