Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is this a bash-ism?

    "$x plus $y equals $((x+y))"


No, it's portable shell syntax.


"$((" arithmetic expansion is POSIX (XCU 2.6.4 "Arithmetic Expansion").

But if I'm not mistaken, it originated in csh.


This works in "sh" as well for me.


On some systems (like on mine) sh is just a link to bash, so I couldn't test it.


Isn't bash supposed to act like sh when executed with that name?


It still has bashisms


> Is this a bash-ism?

> "$x plus $y equals $((x+y))"

No, it is specified in POSIX: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: