Zsh Mailing List Archive
Messages sorted by:
Re: Airthmetic confusion...
- X-seq: zsh-users 8849
- From: Meino Christian Cramer <Meino.Cramer@xxxxxx>
- To: schaefer@xxxxxxxxxxxxxxxx
- Subject: Re: Airthmetic confusion...
- Date: Tue, 17 May 2005 16:57:49 +0200 (CEST)
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <1050517034852.ZM26898@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <3060c239050516135933fd2ff6@xxxxxxxxxxxxxx> <20050517.051316.74748513.Meino.Cramer@xxxxxx> <1050517034852.ZM26898@xxxxxxxxxxxxxxxxxxxxxxx>
From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
Subject: Re: Airthmetic confusion...
Date: Tue, 17 May 2005 03:48:52 +0000
Thanks a lot for your explicit explanations.
> 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 ))
> 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.
Messages sorted by: