LWN.net Logo

shell arithmetic is not a "bashism"

shell arithmetic is not a "bashism"

Posted Aug 7, 2009 20:34 UTC (Fri) by branden (subscriber, #7029)
In reply to: shell arithmetic is not a "bashism" by vapier
Parent article: A tale of two shells: bash or dash

It depends on which kind of shell arithmetic you're talking about.

The article's author may have been thinking of:

bash$ if (( 2 + 2 )); then echo yes; fi
yes

ash$ if (( 2 + 2 )); then echo yes; fi
ash: 2: not found

As the bash manpage notes, "This is exactly equivalent to let "expression"."

"let" isn't SUSv3, so (( )) isn't either.

You are probably thinking of:

$ echo $(( 2 + 2 ))
4

Which *is* SUSv3.


(Log in to post comments)

shell arithmetic is not a "bashism"

Posted Sep 4, 2009 10:32 UTC (Fri) by vapier (subscriber, #15768) [Link]

really you just backed up my point. while bash does have arithmetical extensions, the phrase used in the article is wrong. you cant lump "shell arithmetic" in with "let", "source", and "echo -e".

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds