Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site redwood.UUCP Path: utzoo!utcs!lsuc!pesnta!amdcad!fortune!redwood!rpw3 From: rpw3@redwood.UUCP (Rob Warnock) Newsgroups: net.unix-wizards Subject: Re: Re: UNIX source vs. binary (NOT A LEGAL ARGUMENT) Message-ID: <168@redwood.UUCP> Date: Wed, 20-Feb-85 05:47:20 EST Article-I.D.: redwood.168 Posted: Wed Feb 20 05:47:20 1985 Date-Received: Wed, 20-Feb-85 17:22:11 EST References: <7982@brl-tgr.ARPA> <97@timeinc.UUCP> <440@down.FUN> <1166@sunybcs.UUCP> <427@lsuc.UUCP> Organization: [Consultant], Foster City, CA Lines: 49 +--------------- | Sorry, that won't work on v7 systems, where you can't execute a shell | file with exec(2), which is what login uses (execlp, actually). | Dave Sherman | {utzoo pesnta nrcaero utcs}!lsuc!dave | {allegra decvax ihnp4 linus}!utcsri!lsuc!dave +--------------- Well, I know that in 4.1bsd "execlp" will run a shell script (and on my F-box here, too), but where is it documented? A look at "exec(2)" in a V.7 manual reveals: Execlp and execvp are called with the same arguments as execl and execv, but duplicate the shell's actions in searching for an executable file in a list of directories. I have always read this to mean that in addition to using "$PATH", execlp/execvp also duplicates the shell's check for legal "magic numbers" (see "a.out(5)") and assumes anything else is a shell script (the 4.?bsd "#!" cookie is treated as a magic number). Checking "sh(1)" we see: Execution ...If the file has execute permission but is not an "a.out" file, it is assumed to be a file containing shell commands. But having my curiosity aroused, I went back to "exec(2)", read further on and found: BUGS If execvp is called to execute a file that turns out to be a shell command file, and if it is impossible to execute the shell, the values of argv[0] and argv[-1] will be modified before return. To be sure, there are clearer ways to say it explicitly (rather than as a side effect of describing a bug), but that pretty much settles it -- Version 7 "execlp/execvp" DOES work (exec a shell) for shell scripts. (Additional minor quibble: given the amount of diddling around it does, execlp/execvp should probably be with the other library routines as "exec(3)", rather than with the "pure" system calls in "exec(2)".) Rob Warnock Systems Architecture Consultant UUCP: {ihnp4,ucbvax!dual}!fortune!redwood!rpw3 DDD: (415)572-2607 USPS: 510 Trinidad Lane, Foster City, CA 94404