[Linux-aus] Re: Bash shell scripting training

Cameron Simpson cs at zip.com.au
Tue Mar 13 08:12:10 UTC 2007


On 13Mar2007 09:58, Williams, Chris <cwilliams at federalit.net> wrote:
| I am looking in to having some BASH shell scripting training.  [...]
| Unless anyone has a better suggestion I use mainly Linux and Solaris machines
| I just figured bash would be the best for any *nix platform.

Nope. Get POSIX shell training, or ksh training. All UNIX systems have a
/bin/sh, and on most modern systems that will be a POSIX compliant
Bourne shell, which is based on ksh.

Bash does not exist everywhere and has many non-standard extensions,
often of dubious value, that will just get you into the habit of writing
scripts that won't work on another platform.

Extensions are all very well for certain limited special needs, _IF_ no
other standard technique works (or they're all VERY VERY inefficient,
which is rare). If you're testing using bash (eg on a Linux box), test
with "bash --posix". Start all your scripts with

  #!/bin/sh

and never

  #!/bin/bash

and you'll shoot yourself in the foot very rarely.

Ok, my ranting is done.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

16 October. I also asked Anthea how many mature oaks she thought it
would have taken to build a top-of-the-line ship in Nelson's day. She
guessed ten. The astonishing answer (from Brewer's) is about 3,500 -
900 acres of oak forest. She said, "I wonder what we're doing now that's
as wasteful as that". I said it's still called Defence.
- Brian Eno, _A Year With Swollen Appendices_




More information about the linux-aus mailing list