Re:Ask HN: Perfect language to use for hopefully widespread ...
by SwellJoe on Saturday February 07, 2009 @07:46PM
(#471635)
BASH in compatibility mode will run almost anything written for sh, plus a few extras. It's the few extras that caused me problems when I was working on FreeBSD, Solaris and Ubuntu 8.04 support. If you are careful not to use those extras, you'll be fine. Unfortunately, not using those extras makes programming in sh even less pleasant. The [[ test operator and the substitution/substring operators were probably the most annoying, in my case--it's easy to convert, it just ratchets up the line count a bit, and you have to be even more careful about what you feed it.
Mostly, I found everything I needed in this Ubuntu guide:
https://wiki.ubuntu.com/DashAsBinSh
So, the BASH/sh dichotomy is not traumatic, by any means. At least not on the platforms I've dealt with it (which, so far, is only Linux of many flavors, FreeBSD, and Solaris--so there may be more issues in the future). But, since there are so many other negatives to working in sh for anything more complicated than a one-off script, I'd probably go for a language better equipped for modularity. Since Perl is pretty close to standard on every UNIX I've ever used, I don't think you lose much, if anything, in the way of cross-platform.
Bash is supposed to behave like sh if it is invoked as /bin/sh. (I'm not sure how good a job it does at this, but at least it tries to be standards-compliant.)