The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: "Jeremy C. Reed" <reed@reedmedia.net>
To: ron minnich <rminnich@gmail.com>
Cc: TUHS main list <tuhs@minnie.tuhs.org>
Subject: Re: [TUHS] Which years saw the introduction of (1) #! and (2) symbolic links
Date: Mon, 28 Dec 2020 19:41:24 -0600 (CST)	[thread overview]
Message-ID: <alpine.NEB.2.21.2012281906520.5010@t1.m.reedmedia.net> (raw)
In-Reply-To: <CAP6exYJMNUuU=EFo659=SEj-coD2eo5_yNGeKzAojDqp1tKObQ@mail.gmail.com>

(Just first question here ...)

Early BSD shells could look at first bytes (0404) to indicate was a 
pascal object to run the Berkeley pascal interpreter.
When csh was introduced, the csh would run the other shell /bin/sh if 
the first character was not a # pound.  So csh used the single # as 
magic to run the script with csh. The # was a comment for csh, make, and 
awk (but not for standard sh which could use a : colon for the comment).

Have a look at top of 4BSD's /usr/src/sys/newsys/sys1.c below. This code 
is not in v7 nor 32V.

From uucp Thu Jan 10 01:37:58 1980
>From dmr Thu Jan 10 04:25:49 1980 remote from research
The system has been changed so that if a file being executed
begins with the magic characters #! , the rest of the line is understood
to be the name of an interpreter for the executed file.
Previously (and in fact still) the shell did much of this job;
it automatically executed itself on a text file with executable mode
when the text file's name was typed as a command.
Putting the facility into the system gives the following
benefits.

1) It makes shell scripts more like real executable files,
because they can be the subject of 'exec.'

2) If you do a 'ps' while such a command is running, its real
name appears instead of 'sh'.
Likewise, accounting is done on the basis of the real name.

3) Shell scripts can be set-user-ID.

4) It is simpler to have alternate shells available;
e.g. if you like the Berkeley csh there is no question about
which shell is to interpret a file.

5) It will allow other interpreters to fit in more smoothly.

To take advantage of this wonderful opportunity,
put

	#! /bin/sh

at the left margin of the first line of your shell scripts.
Blanks after ! are OK.  Use a complete pathname (no search is done).
At the moment the whole line is restricted to 16 characters but
this limit will be raised.


From uucp Thu Jan 10 01:37:49 1980
>From dmr Thu Jan 10 04:23:53 1980 remote from research


      parent reply	other threads:[~2020-12-29  2:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-29  0:30 ron minnich
2020-12-29  1:04 ` Ron Natalie
2020-12-29  2:07   ` Clem Cole
2020-12-29  5:03     ` ron minnich
2020-12-30 17:15       ` Clem Cole
2020-12-29  1:41 ` Jeremy C. Reed [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.NEB.2.21.2012281906520.5010@t1.m.reedmedia.net \
    --to=reed@reedmedia.net \
    --cc=rminnich@gmail.com \
    --cc=tuhs@minnie.tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).