[comp.os.minix] executable scripts?

klamer@mi.eltn.utwente.nl (Klamer Schutte) (05/02/91)

In <1991Apr29.110459.25477@doe.utoronto.ca> david@doe.utoronto.ca (David Megginson) writes:
>I am also interested in executable scripts. Right now, when I make a
>script executable, the kernel always seems to presume that it is for
>sh. I would like to have executable scripts like

>	#!	/usr/gnu/bin/gawk

BSD unix systems recognise the #! as a magic word and execute it with the
proper interpreter. Small unix systems does not.

However, a proper shell >>should<< look at the first two characters of a
script it gets (when the script is executable). Since minix sh does not,
i declare it as broken. ;-)

Klamer
-- 
Klamer Schutte
Faculty of electrical engineering -- University of Twente, The Netherlands
klamer@mi.eltn.utwente.nl	{backbone}!mcsun!mi.eltn.utwente.nl!klamer

overby@plains.NoDak.edu (Glen Overby) (05/03/91)

In article <klamer.673173576@mi.eltn.utwente.nl> klamer@mi.eltn.utwente.nl (Klamer Schutte) writes:
>BSD unix systems recognise the #! as a magic word and execute it with the
>proper interpreter. Small unix systems does not.

>However, a proper shell >>should<< look at the first two characters of a
>script it gets (when the script is executable). Since minix sh does not,

I disagree.  The shell should not be looking at executables; it should
merely "exec" them and the kernel should determine what is REALLY done with
the executable, be it loaded as a binary image or fed through an interpreter.

By requiring the "shell" to check for executable scripts, you complicate any
program which chooses to use exec(2) since it, too, must open the executable
and check for an interpreter.  Any executable should be "exec"-able.

I don't have P1003.1 with me, so I can't check if it addresses this issue.
--
                Glen Overby     <overby@plains.nodak.edu>
        uunet!plains!overby (UUCP)  overby@plains (Bitnet)

sean@mks.com (Sean Goggin) (05/03/91)

In article <10120@plains.NoDak.edu> overby@plains.NoDak.edu (Glen Overby) writes
>In article <klamer.673173576@mi.eltn.utwente.nl> klamer@mi.eltn.utwente.nl (Klamer Schutte) writes:
>>However, a proper shell >>should<< look at the first two characters of a
>>script it gets (when the script is executable). Since minix sh does not,
>
>I disagree.  The shell should not be looking at executables; it should
>merely "exec" them and the kernel should determine what is REALLY done with
>the executable, be it loaded as a binary image or fed through an interpreter.
>
>By requiring the "shell" to check for executable scripts, you complicate any
>program which chooses to use exec(2) since it, too, must open the executable
>and check for an interpreter.  Any executable should be "exec"-able.

I hope this helps.

Command search and execution 3.9.1.1
P1003.2/D10 p178 line 1075-1079
System API [C language]
P1003.1/D05 p12  line 53-54

If execve() fails due to an error equivalent to 
ENOEXEC the shell shall execute a command
equivalent to having a shell invoked with the command name as its
first operand, long with any remaining arguments.

ENOEXEC = new process image file has access permission,
but has an unrecognized format.

Sean Goggin
	  
	

-- 
Sean.Goggin..sean@mks.com.............Mortice.Kern.Systems.Waterloo.Ontario.Can.

klamer@mi.eltn.utwente.nl (Klamer Schutte) (05/06/91)

In <10120@plains.NoDak.edu> overby@plains.NoDak.edu (Glen Overby) writes:

->In article <klamer.673173576@mi.eltn.utwente.nl> klamer@mi.eltn.utwente.nl (Klamer Schutte) writes:
->>BSD unix systems recognise the #! as a magic word and execute it with the
->>proper interpreter. Small unix systems does not.

->>However, a proper shell >>should<< look at the first two characters of a
->>script it gets (when the script is executable). Since minix sh does not,

->I disagree.  The shell should not be looking at executables; it should
->merely "exec" them and the kernel should determine what is REALLY done with
->the executable, be it loaded as a binary image or fed through an interpreter.

Yes, it can be changed. Just a couple of changes in mm.
Hey world (Andy, are you listening), how do you think about this change?

->By requiring the "shell" to check for executable scripts, you complicate any
->program which chooses to use exec(2) since it, too, must open the executable
->and check for an interpreter.  Any executable should be "exec"-able.

No, from all programs only sh should do this. This because all existing 
programs (to my knowledge, at least) first try an exec() and if that fails 
they try to get the program executed by sh(1) (by means of exec'ing /bin/sh).

->I don't have P1003.1 with me, so I can't check if it addresses this issue.
Neither can i.

Klamer
-- 
Klamer Schutte
Faculty of electrical engineering -- University of Twente, The Netherlands
klamer@mi.eltn.utwente.nl	{backbone}!mcsun!mi.eltn.utwente.nl!klamer