[Top][All Lists]

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

Re: <OK> [Groff] serious pdfroff problems

From: Keith MARSHALL
Subject: Re: <OK> [Groff] serious pdfroff problems
Date: Thu, 16 Jun 2005 16:32:09 +0100

> I agree with all you say, up to the idea that  #!/bin/sh  is
> appropriate.

IMO, it is entirely appropriate.

> Whoever writes a shell writes against one of the non-universal models
> because there is no universal model.  By documenting which model is in
> use, we know which man page to read when looking for bugs.  And
> explicitly pointing at the _matching_ model prevents bugs from being
> expressed.  Assuming that which ever shell happens to be /bin/sh in
> the current environment is going to work strikes me as too risky once
> you get beyond sequential command executions.

The purpose of the shebang is not to document which shell a script is
written for, but to tell the current shell which interpreter it should
spawn, to execute the script.  When a script is written for a minimal
subset of standard Bourne shell, which is expected to be portable, then
/bin/sh is the most appropriate interpreter, regardless of the user's
choice for interactive service.

If the shebang is omitted, then the user's chosen interactive shell will
simply try to interpret the script itself.  That's fine, if the user's
chosen shell can parse and execute Bourne syntax, but what happens if it
can't?  (csh is particularly notorious, in this respect).  By explicitly
announcing that Bourne shell should be the preferred interpreter, we
give our script its best chance of executing successfully, IMHO.

> I never looked before, but these are the shells on my Linux.  I live
> in pdksh.
>                                /bin/ash*
>                                /bin/bash*
>                                /bin/bsh -> ash*
>                                /bin/csh -> tcsh*
>                                /bin/ksh -> pdksh
>                                /bin/pdksh*
>                                /bin/sh -> bash*
>                                /bin/tcsh*
>                                /bin/zsh*

With, or without the shebang, you should be ok with pdksh;  I would be
less encouraged, if you were to opt for csh, and didn't have the
shebang.  Since you have the /bin/sh -> bash symlink, the shebang will
select bash to run the script, which should surely be successful -- it's
what I use for choice on *all* my boxes.  (Of course, this means that
the scripts I write are most thoroughly tested using bash, which,
because I can't rely on its ubiquity, is why I value feed back from
users of other shells, when problems arise).

> The good news in all of this is that the open/free software world lets
> us have discussions like this.

Hear, hear.

Best regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]