On Wed, Nov 30, 2005 at 01:15:11PM +0100, Gerrit Pape wrote:
[snip]
> > 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)).

No, it talks about $((expression))

x+1 for instance is a perfectly valid expression.
$x+1 is another one (and should do the exact same thing).

[snip]

> > [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'

Yes, indeed, sorry about that one.

[snip]

> > [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.

Fair enough.  I find it strange that it's not mentioned; after all it's
the only way to do multiple assigments within an arithmetic expression
(that I can think of).  But since I cannot find any support for this
either, just ignore it for now.

[snip]


Regards: David
-- 
 /) David Weinehall <[EMAIL PROTECTED]> /) Rime on my window           (\
//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   //  Diamond-white roses of fire //
\)  http://www.acc.umu.se/~tao/    (/   Beautiful hoar-frost       (/


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

Reply via email to