[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Another new 4.0 feature? functions can't return '1', (()) can't eval
Re: Another new 4.0 feature? functions can't return '1', (()) can't eval to 0?
Tue, 09 Aug 2011 21:08:33 -0400
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:18.104.22.168) Gecko/20110616 Lightning/1.0b2 Thunderbird/3.1.11
On 8/9/11 8:10 PM, Linda Walsh wrote:
>> The change to make (( honor the `errexit' option came in with bash-4.1,
>> part of the cleanup after the Posix changes to the specification of the
>> behavior of `set -e'. Most of the other changes in this area came in
>> with bash-4.0.
> I thought (()) was a bash extension?
It is. That's not a reason to make `set -e' apply non-uniformly.
> If so, why shoe-horn it into a 20y/o spec**? It's often used for
> doing calculations -- that's why it was added... it can only be used
> where a command can be used, so having it die whenever it evals to 0 -- just
> doesn't make sense. If there's an error in the calculation, like division
> by zero, sure, but just because I come up with a result of 0, == it's a far
> stretch to think that would be an error.
There are ways around this, if it's an issue.
> Did you get bitten by some POSIX virus?
That didn't end up being nearly as funny as you probably thought it
was going to be.
>> Posix changed set -e to cause the shell to exit when any command fails,
>> not just when simple commands fail, as in versions of the standard up
>> to and including Posix.1-2008.
> (()) isn't a command, it's a calculation (how's that for different
Creative, but it's a command.
>>> 2) a function returning a false value -- Tried putting the ((expr)) in
>>> an if:
>>> if ((expr)); then return 0; else return 1;
>>> As soon as it sees the return 1, it exits, -- as I returned 'false'
> It was followed by an &&, has that changed too?
It's impossible to say what the problem, if any, might have been.
For instance, the following script displays `after':
if (( 0 )); then return 0; else return 1; fi
func && echo a
> ** -- wait, I thought posix was dead ages ago....there are updates? 2008?
> is that
> the latest? #*(@#$()@#)!@)*&% they whole reason for the standard was so
> wouldn't keep breaking...and now they change the standards...
Maybe you should read it; you'll see that work is continuing.
We're about to ballot on Technical Corrigendum 1 (TC1) to the 2008
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/