On Sun, Sep 25, 2005 at 07:56:47PM +0000, Gerrit Pape wrote:
> Hi David,
>
> 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.
> > Also:
> >
> > ``All changes to variables in an arithmetic expression shall be in effect
> > after the arithmetic expansion, as in the parameter expansion
> > "${x=value}".''
>
> AIUI, looks like dash already does this. Can you show where exactly you
> want dash to behave differently?
>
> $ dash -c 'unset x; echo $((${x=14})); echo ${x=41}'
> 14
> 14
> $
Yes, but:
[EMAIL PROTECTED]:~# dash -c 'unset x; echo $(($x=14)); echo $x'
dash: arith: syntax error: "=14"
[EMAIL PROTECTED]:~# dash -c 'unset x; unset y; echo $((${x=3},${y=4})); echo
$x $y'
dash: arith: syntax error: "3,4"
compare with bash:
[EMAIL PROTECTED]:~# bash -c 'unset x; echo $((x=14)); echo $x'
14
14
[EMAIL PROTECTED]:~# bash -c 'unset x; unset y; echo $((${x=3},${y=4})); echo
$x $y'
4
3 4
and posh:
[EMAIL PROTECTED]:~# posh -c 'unset x; echo $((x=14)); echo $x'
14
14
[EMAIL PROTECTED]:~# posh -c 'unset x; unset y; echo $((${x=3},${y=4})); echo $x
$y'
4
3 4
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]