[TUHS] History of #! interpretation in Unix
Sven Mascheck
mascheck at in-ulm.de
Mon Jan 17 05:19:42 AEST 2011
John Cowan wrote:
> Sven Mascheck scripsit:
>
> > As you mention "shebangs began .. as csh-only hack":
> > I still wonder if one may call the BSD csh-hack as origin,
> > because #! might have been developed independently at Bell Labs.
>
> No, that would be too much of a coincidence to choose exactly the
> same characters. There has to be a single point of origin, from
> which it spread by stimulus diffusion (you hear there are telescopes,
> you know they use lenses, you build your own telescope).
This doesn't sound obligatory to me (I know it's academic).
DMR might have known the csh-hack (and if a comment character is
implemented anywhere, here csh, then it's obvious to use it for #!)
> > I thought sh-like shells in general try to interprete scripts themselves
> > upon an ENOEXEC. Do you know certain shells which actually call "/bin/sh"?
>
> Yes, seemingly bash does that too. Bogus.
How'd you get the impression? I can't verify this.
bash-1.05:execute_cmd.c executed the commands itself, in a subshell,
" [ errno == ENOEXEC ]
/* This file is executable.
If it begins with #!, then help out people with losing
operating systems. Otherwise, check to see if it is a binary
file by seeing if the first line (or upto 30 characters) are in
the ASCII set. Execute the contents as shell commands. */ "
and this hasn't been changed (except length or return status)
until the current release.
Perhaps you had another shell in mind? I believe a shell should
try to execute commands itself instead of calling any other shell.
(That's the only way how executing on in POSIX shell is possible, BTW,
because neither #! nor paths are standardized).
More information about the TUHS
mailing list