From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15779 invoked from network); 17 May 2005 03:12:53 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 17 May 2005 03:12:53 -0000 Received: (qmail 51787 invoked from network); 17 May 2005 03:12:47 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 May 2005 03:12:46 -0000 Received: (qmail 25653 invoked by alias); 17 May 2005 03:12:39 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8838 Received: (qmail 25635 invoked from network); 17 May 2005 03:12:37 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 May 2005 03:12:37 -0000 Received: (qmail 50732 invoked from network); 17 May 2005 03:12:37 -0000 Received: from p54852a2f.dip0.t-ipconnect.de (HELO solfire) (84.133.42.47) by a.mx.sunsite.dk with SMTP; 17 May 2005 03:12:32 -0000 Received: from localhost ([127.0.0.1]) by solfire with esmtp (Exim 4.42) id 1DXsWC-0003Sp-R9; Tue, 17 May 2005 05:13:21 +0200 Date: Tue, 17 May 2005 05:13:16 +0200 (CEST) Message-Id: <20050517.051316.74748513.Meino.Cramer@gmx.de> To: sequethin@gmail.com Cc: Berndt.Matthias@gmx.de, zsh-users@sunsite.dk From: Meino Christian Cramer In-Reply-To: <3060c239050516135933fd2ff6@mail.gmail.com> References: <20050516.195529.74749456.Meino.Cramer@gmx.de> <20050516224332.246839a4@localhost> <3060c239050516135933fd2ff6@mail.gmail.com> X-Mailer: Mew version 4.1 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Rcpt-To: sequethin@gmail.com, Berndt.Matthias@gmx.de, zsh-users@sunsite.dk X-SA-Exim-Mail-From: Meino.Cramer@gmx.de Subject: Re: Airthmetic confusion... Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SA-Exim-Version: 4.1+cvs (built Sat, 28 Aug 2004 13:10:40 +0200) X-SA-Exim-Scanned: Yes (on solfire) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-0.5 required=6.0 tests=AWL,BAYES_00, RCVD_IN_NJABL_DUL,RCVD_IN_SORBS_DUL,RCVD_IN_SORBS_WEB autolearn=no version=3.0.2 X-Spam-Hits: -0.5 From: Mike Hernandez Subject: Re: Airthmetic confusion... Date: Mon, 16 May 2005 16:59:27 -0400 Hi, I see that "0" is false and !0 is true...but...we are doing arithmetic and not logical evaluation. Suppose the following situation: There is a script which first line set set -e (exit on error), because your script do something not-undoable. Inside the script there is a claculation, which has to do correct thing in the sense of for example not accessing inexistant variables or not accessing arrays out of bounds. The calculations are of non-trivial nature (that's why we let the computer do such boring tidy things ;) Now a calculation returns "0" as its result and BANG! the script exits. ? Not what was intended, I think. As a sideffect a previously existant variable become inexistant by assigning a "0"? Not very logical I think.... :O) Arithmetic evaluation should be sperated from logical evaluation. Happy zshing! Meino > On 5/16/05, Matthias Berndt wrote: > > I don't know your problem, but these expression works fine here. Did you > > make something special before or in your startup-scripts? > > Actually what happens is that the operation and assignment are > performed but the return code of the expression evaluates to 1, which > is an error. I tried on my machine and get the same results: > > (mike@mhernandez)(24/pts)(04:45pm:05/16/05)- > (%:~)- (( x = 0 )) > (mike@mhernandez)(25/pts)(04:46pm:05/16/05)- > (%:~)- echo $? > 1 > (mike@mhernandez)(26/pts)(04:46pm:05/16/05)- > (%:~)- echo $x > 0 > > If you set a variable to any integer other than 0, positive or > negative, the return code is 0, which is successful exit, for example: > > (mike@mhernandez)(30/pts)(04:53pm:05/16/05)- > (%:~)- (( r = -5 )) > (mike@mhernandez)(31/pts)(04:53pm:05/16/05)- > (%:~)- echo $? > 0 > > This occurs with a regular assignment as above, or if the assignment > contains some variables (as in x = b - 4, if b was 4 the return code > would be 1, yet the math is done and x is set to equal 0). > > There must be a reason why assigning 0 to a variable is considered an > error (a reason which I could speculate about, but don't know for > sure). > > Mike >