[net.unix-wizards] blood curdling exec

hanss (10/29/82)

With appologies to dmr.

Yes, I said it wrong again.  the 4.1  '#! /bin/csh'
syntax is in exec, not the shell!  and they did document it,
but in the page for exec(2), not the shell page.

As the wise philosopher alluded to above put it:
If theres a bug in the shell, fix the shell, dont hack the system to
work around it.

I admit that putting this function into the system makes it more efficient
and allows you to implement any script muncher you may want as a filter,
but it fixes the comment syntax of all such things.  how about
#! /bin/cc for example?   No wonder the army likes BSD.  They liked
cobol and OS 360 too.

				Afraid to admit my alma mater
				-Hans
				UC Berkeley AB CS '78
				decvax!microsoft!hanss

nrh (11/02/82)

#R:microsof:-255900:esquire:900005:000:762
esquire!nrh    Oct 31 13:14:00 1982

I just brought up a 4.1 BSD system, and kind of like the 
#! idea.  The question of where the interpreter gets invoked
is the issue.  In the old case, it had to be invoked explicitly, 
and the idea of "an executable" was something that could be
interpreted by the hardware.  The new setup shifts the meaning of
"an executable" to "a file executable either by hardware or by 
other software".

Since the shell is not the only way in which files can be executed
(did you ever try making someone's login shell be a command file?)
it seems unreasonable that the shell should bear the burden of 
doing all the work for setting up an interpreter (unless you 
feel that the shell should do all the work of finding memory, etc
for the binary executable to live in too).

cak@Purdue@sri-unix (11/16/82)

From: Christopher A Kent <cak@Purdue>
Date: 11 Nov 1982 08:40:35-EST
#! /bin/cc 
at the beginning of a shell script works just fine, EXCEPT FOR ONE THING.
The whole file gets passed as input to the command, rather than the
whole file minus the first line; we found this out when we tried

#! /bin/cat
text of message

and couldn't get rid of the first line. 

Of course, fixing this would make the kernel understand what a
"line" means, which would be even more bletcherous....

Cheers,
chris

chris.umcp-cs@UDel-Relay@sri-unix (11/19/82)

From:     Chris Torek <chris.umcp-cs@UDel-Relay>
Date:     16 Nov 82 03:28:13 EST  (Tue)
Everyone seems to be making the same mistake (I've done it myself).
The script starting with "#!" is NOT set up as the standard input.
It is passed as argv[1] to the program.  If you think about this for
a moment the difficulty of skipping that first line becomes obvious.
That's why I sent the original message, "does anyone know if this
has been cleaned up in 4.2?".  I don't have any suggestions for it
but maybe someone else does.  Remember: argv[1], not file 0.

fred.umcp-cs@UDel-Relay@sri-unix (11/20/82)

From:     Fred Blonder <fred.umcp-cs@UDel-Relay>
Date:     16 Nov 82 19:07:16 EST  (Tue)
From:     Doug Gwyn <gwyn@Brl>
	
	It seems to me that the place to put the #! recognizer is in the
	system library, not in the kernel exec handler.  However, this
	would work only on readable (not merely executable) scripts...

But the script has to be readable anyway. The interpreter must open the file
for reading. It does NOT have its standard input redirected to the script.
That way ``#!'' scripts can participate in pipes.

ark (11/20/82)

The reason the #! hack has to be in the kernel is that that is the
only way, short of making the Shell a suid program, of allowing
"suid shell scripts."  Please don't flame at me that suid shell scripts
are inherently insecure -- this may be so, or it may not, but the Shell
is not the only program in the world that can act as an interpreter.

kermit@Brl@sri-unix (11/21/82)

From:     Charles Kennedy <kermit@Brl>
Date:     17 Nov 82 23:05:18-EST (Wed)
Actually DARCOM does like BSD (you seemed to imply otherwise),
however, the support issue was what caused DARCOM to RECOMMEND
Bell UNIX for use by its activities.
					-kermit