Path: utzoo!utgpu!water!watmath!clyde!rutgers!im4u!ut-sally!bcm!rice!titan!phil From: phil@titan.rice.edu (William LeFebvre) Newsgroups: comp.sys.amiga Subject: Re: Suggestion for assignment of another protection bit Message-ID: <521@ra.rice.edu> Date: 8 Jan 88 22:43:06 GMT References: <8712240640.AA24010@cory.Berkeley.EDU> <37368@sun.uucp> Sender: usenet@rice.edu Reply-To: phil@Rice.edu (William LeFebvre) Organization: Rice University, Houston Lines: 38 In article <37368@sun.uucp> cmcmanis@sun.UUCP (Chuck McManis) writes: >In article <8712240640.AA24010@cory.Berkeley.EDU> (Matt Dillon) writes: >> As far as execution goes, why not adopt the UNIX standard: >> >>#!C:EXECUTE (as the first line in file) > >But Matt even on UNIX the shell does this, not the O/S. You could use the >same technique that csh uses, check the file to see if it is a binary >file (read the first 'hunk header') and look for non ascii characters. >If binary run it as is, if it is text then check the first line for a >processor name and prepend that to the arglist and then try to run it >again (now executing the shell). A binary/text bit would be nice to >speed this up. (This would also make TYPE default to HEX mode.) Let's set the record straight on this.....the Unix kernel call "exec" DOES check the first two byts of a file to see if they are "#!" and if so, execs the name that follows (while doing some underhanded magic to the arguments). The shell does NOT explicitly check a file to see if it is binary. It first calls some flavor of "exec" with the command name. If the call returns ENOEXEC (not an executable file), then (and only then) it tries to run the file as a shell file. If the first "exec" fails for some reason other than ENOEXEC, the error message is (in most cases) printed on the user's terminal. As far as doing a "#!" equivalent under AmigaOS, at the very least, it would have to be ";!". The letter "#" was not chosen at random---it is the shell's comment character. Since the entire file is handed to the requested executable, this first line must somehow be ignored by that executable. In the case of Unix, this automatically happens because it looks like a comment. Unfortunately for the Amiga, this means that more programs would need to agree on a comment character or some other scheme would have to be employed to insure that the first line was not acted upon by the invoked program. William LeFebvre Department of Computer Science Rice University