Subject: Re: Changing exec's #! behavior
To: None <>
From: Robert Elz <kre@munnari.OZ.AU>
List: tech-kern
Date: 06/15/2000 22:48:59
    Date:        Tue, 13 Jun 2000 17:25:32 -0700
    From:        Jason R Thorpe <>
    Message-ID:  <>

  | I guess I should also clarify -- passing the entire argv vector
  | seriously complicates exec_script

That was part of the reason that only one arg was allowed, but only
a small part - had it been reasonable to allow more, the implementation
would have been fixed (and since I stuck #! in BSD kernels, based upon
an idea and early implementation that I was told came from Dennis Ritchie
I think I can say that..)

Christos had it almost right, except he said "interpreter" where "arg"
would have been accurate.

It was always reasonable to not allow a space to exist in the interpreter
name, those were (are) supposed to be things like /bin/sh or /usr/pkg/bin/perl
(or even /home/me/bin/whatever) - and it is very rare to ever want to stick a
space in one of those paths (in a unix system) - so rare that making that
impossible to work with the #! seemed like a reasonable compromise.

But forbidding the arg being passed to that interpreted from containing
a space (or almost anything else - though \n and \0 had to be excluded)
seemed like a very poor idea - which meant that the kernel would have
needed either shell like quoting mechanisms built in, or we were limited
to a single argument (and giving the limited line length that was available
at the time, and probably still, the way the implementation was done, one
arg also seemed entirely reasonable).

The original idea (as I first saw it) was for sh scripts, where the #! would
just be #! /bin/sh with no args at all.  When I saw this, I wanted to add
awk as an interpreter that would work, and that needed an arg to be able
to exist, the obvious caseis:

	#! /usr/bin/awk -f
	# awk script goes here

But I also wanted to be able to do (and can still do on NetBSD) ...

	#!/usr/bin/awk NR > 1 {print $1}

which (as a one line file) works just fine as a "print column 1" program,
which is perhaps pretty silly (col works better usually), but {print $1 + $2}
is something that is harder other ways.

For that to work, space is essential "print$1" doesn't do the same thing
at all...

Please don't break this - and certainly please don't break it to do
anything at all to assist perl which goes out of its way (these days,
old perl as it was created was a useful tool) to abuse almost everything
in creation.

Sure, awk can just use "-f" and put the script in the file, but not
everything can, some progs only take cmd line args.

So, either implement \ escaping or something, or leave it as one arg
to end of line.   I suggest the latter.


ps: to whoever asked for #! to be able to refer to another #! script,
that wasn't done because dealing with recursive #! scripts would have been
a true pain to deal with, and I suspect, still would be (that is a script,
which directly or indirectly, attempts to run itself).