From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2755 invoked from network); 17 May 2005 03:49:17 -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:49:17 -0000 Received: (qmail 74133 invoked from network); 17 May 2005 03:49:10 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 May 2005 03:49:10 -0000 Received: (qmail 12540 invoked by alias); 17 May 2005 03:49:03 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8840 Received: (qmail 12514 invoked from network); 17 May 2005 03:49:01 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 May 2005 03:49:01 -0000 Received: (qmail 72975 invoked from network); 17 May 2005 03:49:01 -0000 Received: from vms048pub.verizon.net (206.46.252.48) by a.mx.sunsite.dk with SMTP; 17 May 2005 03:48:57 -0000 Received: from candle.brasslantern.com ([4.11.1.68]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IGM004AB7XHW4J4@vms048.mailsrvcs.net> for zsh-users@sunsite.dk; Mon, 16 May 2005 22:48:54 -0500 (CDT) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j4H3mq6c026900 for ; Mon, 16 May 2005 20:48:52 -0700 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j4H3mq2c026899 for zsh-users@sunsite.dk; Mon, 16 May 2005 20:48:52 -0700 Date: Tue, 17 May 2005 03:48:52 +0000 From: Bart Schaefer Subject: Re: Airthmetic confusion... In-reply-to: <20050517.051316.74748513.Meino.Cramer@gmx.de> To: zsh-users@sunsite.dk Message-id: <1050517034852.ZM26898@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <20050516.195529.74749456.Meino.Cramer@gmx.de> <20050516224332.246839a4@localhost> <3060c239050516135933fd2ff6@mail.gmail.com> <20050517.051316.74748513.Meino.Cramer@gmx.de> Comments: In reply to Meino Christian Cramer "Re: Airthmetic confusion..." (May 17, 5:13am) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On May 17, 5:13am, Meino Christian Cramer wrote: } } I see that "0" is false and !0 is true...but...we } are doing arithmetic and not logical evaluation. No, that's not true. First of all, the closest thing to "logical" evaluation that the shell does is the &&, ||, etc., subexpressions WITHIN arithmetic expressions. The && and || constructs that test process success or failure are NOT "logical" operators -- for one thing, they do not obey the usual Boolean precedence rules. "set -e" is not a "logical" comparison by any stretch. Second, when you write (( expression )) then you are explicitly instructing the shell to do BOTH arithmetic evaluation AND shell expression success/failure. That's what the double parens MEAN, when not preceded by a dollar sign. If you want ONLY arithmetic evaluation, use $(( expression )), and apply the colon command if necessary, e.g. : $(( x = a - b )) or x=$(( a - b )) Those are both successful shell expressions that result in zero- value assignments to x. As with any other programming language, you have to write exactly what you mean, and you have to follow the language's semantic rules, not the rules as you think they should be. } As a sideffect a previously existant variable become inexistant by } assigning a "0"? What makes you believe that's happening? Assignments can only create variables, they can't unset them.