Tugger the SLUGger!SLUG Mailing List Archives

Re: [chat] portable scripting


On Mon, Jan 27, 2003 at 09:32:10PM +1100, Ken Foskey wrote:
> I want to write a portable script that must pass environment variables
> to a configure script.  If I use #!/bin/sh will "export CC=/path/to/CC"
> always work?  This does not work with tcsh and there is a slight
> possibility that this is the only shell installed and symlinked to sh.

configure scripts can be passed CC via the command line:

./configure CC=/path/to/cc

<note>
I've noticed that on some systems (Solaris in fact) doing this with LD
doesn't always work since some CC's will use whatever LD they feel like
anyway, and since conftests usually don't link explicitly, it will generally
configure fine then fail to make.
</note>

> This script must be 100% reliable, what is the chances of /bin/sh being
> a non-bourne shell?

AFAIK, 0.  /bin/sh is Bourne-compatible by definition.  At least on
FHS-based systems (http://www.pathname.com/fhs/2.2/fhs-3.4.html), which
covers Debian at least :).  Anyway, I don't recall ever seeing a csh script
that didn't explicitly #! csh or tcsh.

Pete, using "#!" as a verb and loving it..
-- 
Pete Ryland
http://pdr.cx/