GOTCHA in Ubuntu - broken shell

Tom Buskey tom at buskey.name
Mon Oct 1 09:43:52 EDT 2007


Scripting non-bourne shell stuff with #!/bin/sh at the top *should* break.
Even if /bin/sh is a link to bash/ksh that changes its behavior based on the
link.  If your code breaks, shame on you.  You shouldn't use
bashisms/kshisms in #!/bin/sh.

If you want bash or ksh, use #!/bin/bash or #!/bin/ksh.  If it doesn't exist
in /bin, put it there where it belongs.

I've been shell scripting for awhile on multiple OSen.  SunOS (not Solaris)
had /bin/csh as the default.  Ultrix had an older version of bourne shell
that didn't do functions.  /bin/sh5 had functions.  Try writing a script
with functions that works on Ultrix, SunOS, Solaris, HP-UX, OSF/1, Irix and
Linux.

Some versions of Linux use PD ksh as /bin/ksh which is missing stuff in true
AT&T ksh as on Solaris, HP, Irix, etc.  SunOS didn't ship with ksh; you had
to install it ($$).  Solaris before 8 didn't have /bin/bash.

At least with shell scripting /bin/sh is always there.  Try perl, python,
tcl/tk.  /bin? /usr/bin, /usr/local/bin, some site dependent place?  Every
OS has had a different place.

This is similar to C coding "All the world's a VAX" where 32 bit code broke
when it went 64 bits due to assuming 32 bit rollovers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20071001/6b42276e/attachment.html 


More information about the gnhlug-discuss mailing list