Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bash scripting across linux and solaris



David wrote:
> Not quite. ?Historical versions of the Bourne shell are not
> POSIX-compliant, but bash aims to be (which is the reason Debian
> symlinks sh to bash). ?So if you call bash as sh, it tries to behave
> like sh without breaking POSIX-compliance.

Well, POSIX aside, if you call bash as sh, it clearly doesn't behave
as sh, as my little experiment with the array showed.

I've since learned that POSIX is based on ksh rather than sh, so POSIX
compliance appears to be an entirely different issue from enforcing
the sh feature subset. Sorry I brought it up.

> My suggestion would be that if you're on GNU/Linux, write for bash,
> don't be afraid of it. ?It's a far superior shell to traditional
> Bourne...

Stipulated, but IIRC the original question was portability between
GNU/Linux and other Unix flavors, like Solaris.

Of course, doing it all in bash, shebang and all, will work provided
bash is installed on or available for the other flavors. Certainly
that's true of Solaris; don't know about others.

Come to think of it, while I'd agree bash is way more comfortable then
sh as an interactive shell, I'm not sure bash is "far superior" as a
script language. Has a few additional, rarely-used features (that can
confuse maintainers) but is otherwise pretty much the same, I'd say.
On the other hand, some of the syntax improvements certainly aid
readability and therefore maintainability; it's just the "far" I'm
disputing.

Derek points out that symlinking /bin/sh to dash was planned for
Lenny, but pulled. The reason is just what you'd expect; switching the
symlink from bash to what amounts to a sh clone broke a bunch of
system scripts whose shebang specified /bin/sh but which relied on
bash features and syntax. The Debian crew still plans to make the
switch, but didn't have all the potentially-broken stuff fixed in time
for Lenny.

Ted







BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org