bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash 'let' can give error


From: Andreas Schwab
Subject: Re: bash 'let' can give error
Date: Fri, 10 Dec 2010 17:05:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Marc Herbert <Marc.Herbert@gmail.com> writes:

>> let intentionally returns status 1 if the value was 0; and status > 1 if
>> there was an error.  Why?  So you can do loops such as:
>> 
>> countdown=10
>> while let countdown--; do ... ; done
>> 
>>> Why does this happen? Is it 'by design'?
>> 
>> Yes.  The same as for 'expr' which is standardized by POSIX to have the
>> same behavior.
>
> This is a design mistake: it trades a few characters for a lot of confusion.

You can always choose to ignore the exit status.  The converse is not
true.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]