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

Treatment of illegal indices



The way zsh treats illegal array indices is pretty ugly. It simply
replaces indices which are 0 (with KSH_ARRAYS unset) or < -length by 1.
This doesn't make much sense and can cause hard-to-detect errors.
Somebody who uses an index of -4711 in a 10-element array almost
certainly doesn't want to address element 1. 

Possible improvements could be:

a) Always print an error message if an illegal index is used.
b) Do nothing if an illegal index is used on the left side of an       
assignment, return an empty value otherwise.
c) Print an error message if an illegal index is used on the left      
side of an assignment, return an empty value otherwise.

Personally, I'd prefer c). And, although I think zsh has too many
options already, an additional option which toggles between a) and c)
could be useful.

What does everybody think? I'd volunteer to make a patch if I get
positive feedback.

- Bernd

-- 
Bernd Eggink
Regionales Rechenzentrum der Universitaet Hamburg
eggink@xxxxxxxxxxxxxxxxxx
http://www.rrz.uni-hamburg.de/eggink/BEggink.html



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