Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP
Path: utzoo!linus!vaxine!wjh12!genrad!decvax!harpo!seismo!rlgvax!guy
From: guy@rlgvax.UUCP (Guy Harris)
Newsgroups: net.unix
Subject: Re: Re:  Shell programming style -- a pl
Message-ID: <1772@rlgvax.UUCP>
Date: Tue, 6-Mar-84 01:07:33 EST
Article-I.D.: rlgvax.1772
Posted: Tue Mar  6 01:07:33 1984
Date-Received: Wed, 7-Mar-84 00:27:11 EST
References: <16945@sri-arpa.UUCP> <34500004@hp-dcd.UUCP>
Organization: CCI Office Systems Group, Reston, VA
Lines: 30

> The only safe form I know of (for forcing a shell script to be executed
> by "sh" and not "csh" - gh) across ALL systems is to write a script that
> begins with a space...

I believe beginning the script with a colon will also work.

For those of you who have tuned in late, all versions of the Bourne shell,
even the V7 one, treat the colon as a command which throws away its arguments
and returns an "exit status" of 0 (it sort of acts like a comment, but it will
parse the text after the colon as arguments to a command, so beware of shell
meta-characters), while the C shell treats it as a signal to run the script
with "/bin/sh".  We've used it on several occasions and it works fine.  The
4.xBSD Bourne shell, and some other Bourne shells on systems with "csh", treat
a script whose *first character* is "#" as something to be run by "csh"
(elsewhere, "#" is just a comment in some Bourne shells), so beginning a
script with "#" may fail for one of the three following reasons:

1) Your Bourne shell may think it flags the script as a C shell script;

2) Your Bourne shell may not know the C shell from Adam, but doesn't understand
that "#" introduces a comment;

3) You used the "#! /bin/sh" construct to force it to be executed by "/bin/sh",
but your system doesn't have the trick (originally concocted by an employee
of Bell Labs, by the way) of the "magic number" "#!" introducing an executable
file header which indicates the pathname of an interpreter to be used to
interpret the contents of the file.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy