[Top][All Lists]

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

Re: <OK> [Groff] serious pdfroff problems

From: Zvezdan Petkovic
Subject: Re: <OK> [Groff] serious pdfroff problems
Date: Thu, 16 Jun 2005 14:45:41 -0400
User-agent: Mutt/1.4.2i

On Thu, Jun 16, 2005 at 09:04:08AM -0400, M Bianchi wrote:
> I also strongly recommend _against_ using  #!/bin/sh  as the first
> line of shell scripts.

And what exactly do you recommend for a script that should run on dozen
different systems?

> There is no shell called "sh" anymore.  It is always one of the other
> shells and they are different enough that it has become unreasonable
> to expect any given shell script to work with all of them.

_Every_ UNIX system has /bin/sh.
All commercial UNIX systems still have Bourne shell although on most of
the updated ones it is made POSIXly correct.
On some BSDs and Linux it is a link to some other shell, but if you take
a look at manual pages you'll see that both ksh and bash behave
differently when called as sh.  They use a subset of their features.
If your script uses that subset too, it should work on all these systems.

> For example, I just discovered that  tcsh  does not understand
> $(command) !

That's why you need #!/bin/sh so that users can choose their shell,
but you choose the shell for your script.

> So any script that uses the  $(command) feature should use
> #!/bin/bash  as the first line, on the rash assumption that bash
> is universal.  (How likely?)

Very unlikely.  Bash is not installed by default on any commercial UNIX
system or BSD.  BSDs allow you to install it as a package.
Korn shell has almost exactly the same features and is available on all
commercial UNIX systems by default.  In OpenBSD it is a default shell
(sh is a hard link to ksh).  FreeBSD has csh (a hard link to tcsh) as a
default.  Many users are quite happy with the features of ksh or tcsh
that they never bother to install bash.

FWIW, Windows Services for UNIX also have tcsh and ksh.
No surprise considering what you get after running
        strings /usr/bin/* | grep BSD
on Windows SFU.

Therefore, any script should start with #!/bin/sh because that is the
only portable way.

Best regards,

        Zvezdan Petkovic

reply via email to

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