bug-bash
[Top][All Lists]
Advanced

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

Re: Is bash dying or dead (was Re: 4.1 is "$((( ))) an 'official operato


From: Chet Ramey
Subject: Re: Is bash dying or dead (was Re: 4.1 is "$((( ))) an 'official operator, if $(( )) isn't?
Date: Wed, 10 Aug 2011 20:02:52 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.18) Gecko/20110616 Lightning/1.0b2 Thunderbird/3.1.11

On 8/10/11 5:59 PM, Linda Walsh wrote:
> 
> Chet Ramey wrote:
>>
>>  Yes.  It's a case of not saving and restoring enough state across
>>  possibly-
>>  recursive calls to the shell parser.  (The assignment statement is the
>>  key
>>  in this case.)
>>
>> > So, I compared subst.c files from bash-4.1-9 and bash-4.2-10 and was
>> > able
>> > to build a patch that it seems to make it work.
>> > So to all you Bash guru's, can this patch be applied with no extra
>> > consequences ?
>>
>>  No.  The code is in there for a reason.  It's part of the fix for
>>  Posix
>>  interpretation 217 (http://austingroupbugs.net/view.php?id=217).
>>
>>  The right fix is to save and restore the right shell context around
>>  recursive calls to the parser.  The attached patch does that, and the
>>  result passes the rest of the test suite (which obviously needs to be
>>  augmented).
> ----
> 
>    Is this a fluke, due to the above changes NOT being 4.1?  Or is this
> construction going to break in 4.2:
> 
>    '$((( )))'

What does `break' mean?  It's already written in a manner more confusing
and obscure than necessary.  What value do you think the extra set of
parens adds?

> 
> I wanted to evaluate something and assign result to a var.
> 
> so:
>   a=$(((-48-16+2**6)))
> gives me 'a=0', but

And it does in bash-4.2 also, but why make things harder on yourself?
If you feel you have to use a redundant set of parens, make the intent
of the code clear:

        a=$(( (-48-16+2**6) ))

> How do I assign something to a?

With an assignment statement.

-- 
``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/



reply via email to

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