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

Re: Airthmetic confusion...

On 5/16/05, Matthias Berndt <Berndt.Matthias@xxxxxx> 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:

(%:~)- (( x = 0 ))
(%:~)- echo $?
(%:~)- echo $x

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:

(%:~)- (( r = -5 ))
(%:~)- echo $?

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


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