From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1185 invoked from network); 22 Feb 1998 15:28:23 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 22 Feb 1998 15:28:23 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id KAA02333; Sun, 22 Feb 1998 10:05:36 -0500 (EST) Resent-Date: Sun, 22 Feb 1998 10:05:36 -0500 (EST) Sender: rz2a022@rrz.uni-hamburg.de Message-ID: <34F03F3C.5FFA09E@rrz.uni-hamburg.de> Date: Sun, 22 Feb 1998 16:07:40 +0100 From: Bernd Eggink Organization: Regionales Rechenzentrum der Uni Hamburg X-Mailer: Mozilla 4.04 [en] (X11; I; Linux 2.0.30 i586) MIME-Version: 1.0 To: Zsh-workers Subject: Treatment of illegal indices Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Resent-Message-ID: <"sRc4v3.0.Oa.0x3yq"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3780 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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@rrz.uni-hamburg.de http://www.rrz.uni-hamburg.de/eggink/BEggink.html