forwarded 329025 upstream
quit

Hi Herbert, please see http://bugs.debian.org/329025 and comments below.
I personally think there's one example dash should support.

On Sat, Nov 05, 2005 at 09:52:17PM +0100, David Weinehall wrote:
> On Sun, Sep 25, 2005 at 07:56:47PM +0000, Gerrit Pape wrote:
> > On Mon, Sep 19, 2005 at 12:06:46AM +0200, David Weinehall wrote:
> > > Please consider implementing full SuSv3 support for arithmetic expansion.
> > > 
> > > http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_04
> > > 
> > > ``If the shell variable x contains a value that forms a valid integer
> > >   constant, then the arithmetic expansions "$((x))" and "$(($x))" shall
> > >   return the same value.''
> > 
> > hmm, can you give an example where this actually is used?
> 
> I use $(()) constructs very frequently to do shell script arithmetics.
> I usually use the form $((x+<val>)), but I've seen others use the
> $(($x+<val>)) form too.

I'm still not sure about this, how to interpret the specification.  It
only talks about $((x)), not $((x+something)).

> > > Also:
> > > 
> > > ``All changes to variables in an arithmetic expression shall be in effect
> > >   after the arithmetic expansion, as in the parameter expansion
> > >   "${x=value}".''

> [EMAIL PROTECTED]:~# dash -c 'unset x; echo $(($x=14)); echo $x'
> dash: arith: syntax error: "=14"

This sould be 
 $ dash -c 'unset x; echo $((x=14)); echo $x'
 
Ok, this one should work,
 
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_04
specifies the rules arithmetic expansion should follow, including '='.

 $ pdksh -c 'unset x; echo $((x=14+7)) $x'
 21 21
 $ posh -c 'unset x; echo $((x=14+7)) $x'
 21 21
 $ dash -c 'unset x; echo $((x=14+7)) $x'
 dash: arith: syntax error: "x=14+7"
 $ 

> [EMAIL PROTECTED]:~# dash -c 'unset x; unset y; echo $((${x=3},${y=4})); echo
> $x $y'
> dash: arith: syntax error: "3,4"

This construct I don't know, a ',' operator isn't mentioned in the
standards, so I don't think dash should be changes for this.

> [EMAIL PROTECTED]:~# posh -c 'unset x; unset y; echo $((${x=3},${y=4})); echo 
> $x
> $y'
> 4
> 3 4

Hmm, strange that posh does this.

Thanks, Gerrit.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to