Mailing List Archive


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

Re: [tlug] Bashing away at Unix



On 3/14/08, Dave Brown <dagbrown@example.com> wrote:

> The POSIX definition of "/bin/sh" is a lot closer to ksh than most
>  UNIX's actual /bin/sh actually comes.
>
>  When I write a shell script that starts with #!/bin/sh, I set my
>  baseline a lot lower than is probably really necessary, because I
>  believe in playing it safe rather than sorry.
>
>  To wit: I expect absolutly no ${variable}:modifier tricks to work ever.
>  I expect [ to be a command, possibly running as a separate process.
>  I expect [[ to not work ever.
>  I expect $(( and $[ not not work at all.  If I want that, I use expr.
>  I expect $( not to work at all either.
>
>  Basically, #!/bin/sh makes me set the bar REALLY REALLY low.  Doing so
>  has not done me any damage yet.

"not done me any damage",  bah you are too modest.  You've summed up nicely
excellent shell script coding standards.  If anything, I set the bar
lower than you
do.  Portability is *everything*, sometimes.

You did not mention white space protection - use of "$@", always double quoting
variable expansion, excessively quoting what might be special characters like
^, etc.

ksh was excellent work for its time and I was a happy user for quite a
long time.
It's orders of magnitude better than csh/tcsh, but sadly less known.  (Did I
mention that the shell basic I wrote was ksh-based?).

> When writing zsh scripts that I know will be running in the latest version of
> zsh, I just go nuts

Amen!  Been there, done that too.  The first total commit to SCM,
build, upload to
xemacs.org, script for XEmacs was done as a gung-ho zsh script mainly
because I was the only one using it at first.  I think it has been redone, but
the zsh version was very clean.

-sb


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links