Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [doogie@xxxxxxxxxx: Bug#163391: unset array[key] where key is non-existent doesn't fail]



On Oct 5,  1:31pm, Clint Adams wrote:
}
} 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.

Exactly.  The variable "aarray" WAS previously set (by "declare -A").
The fact that a particular hash key was not assigned-to is irrelevant.

zsh -c 'typeset non_existant_var;
	unset non_existant_var && echo consistent || echo inconsistent'

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



Messages sorted by: Reverse Date, Date, Thread, Author