From owner-freebsd-current Mon Aug 14 10:06:50 1995 Return-Path: current-owner Received: (from majordom@localhost) by freefall.FreeBSD.org (8.6.11/8.6.6) id KAA01478 for current-outgoing; Mon, 14 Aug 1995 10:06:50 -0700 Received: from mail.cs.tu-berlin.de (mail.cs.tu-berlin.de [130.149.17.13]) by freefall.FreeBSD.org (8.6.11/8.6.6) with ESMTP id KAA01458 for ; Mon, 14 Aug 1995 10:06:44 -0700 Received: from caramba.cs.tu-berlin.de (wosch@caramba.cs.tu-berlin.de [130.149.144.4]) by mail.cs.tu-berlin.de (8.6.12/8.6.12) with ESMTP id SAA01418; Mon, 14 Aug 1995 18:55:00 +0200 From: Wolfram Schneider Received: (wosch@localhost) by caramba.cs.tu-berlin.de (8.6.12/8.6.9) id SAA16905; Mon, 14 Aug 1995 18:54:50 +0200 Date: Mon, 14 Aug 1995 18:54:50 +0200 Message-Id: <199508141654.SAA16905@caramba.cs.tu-berlin.de> To: Garrett Wollman Cc: current@freebsd.org Subject: make(1) extension for SHELL COMMANDS In-Reply-To: <9508141535.AA11245@halloran-eldar.lcs.mit.edu> References: <199508132144.XAA25996@localhost> <9508141504.AA11190@halloran-eldar.lcs.mit.edu> <199508141513.RAA12434@caramba.cs.tu-berlin.de> <9508141535.AA11245@halloran-eldar.lcs.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: current-owner@freebsd.org Precedence: bulk Garrett Wollman writes: >> Note: the following example don't use /bin/sh in BSD make, our make >> use execv(3) > >Well, that's yet another way in which pmake is broken with respect to >POSIX. I'm not at all surprised to hear it. We don't need to make >the situation even worse than it already is. FYI: GNU-make use a similar algorithm (first exec and if errno=ENOEXEC SHELL). $ uname -rs SunOS 5.4 $ make -v GNU Make version 3.70, by Richard Stallman and Roland McGrath. Copyright (C) 1988, 89, 90, 91, 92, 93 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1. with /bin/sh $ cat Makefile date: date "+%D <>" $ truss -fo /tmp/truss make date "+%D <>" 08/14/95 <> $ egrep 'fork|exec' /tmp/truss 10625: execve("/usr/local/zib_bin/make", 0xEFFFF810, 0xEFFFF818) argc = 1 10625: fork() = 10626 10626: fork() (returning as child ...) = 10625 10626: execve("/bin/sh", 0x00057E98, 0x00057CF8) argc = 3 10626: fork() = 10628 10628: fork() (returning as child ...) = 10626 10628: execve("/usr/bin/date", 0x00036470, 0x00036538) argc = 2 2. without /bin/sh (no meta chars) $ cat Makefile date: date $ truss -fo /tmp/truss make date Mon Aug 14 18:28:50 MET DST 1995 $ egrep 'fork|exec' /tmp/truss 10641: execve("/usr/local/zib_bin/make", 0xEFFFF810, 0xEFFFF818) argc = 1 10641: fork() = 10642 10642: fork() (returning as child ...) = 10641 10642: execve("/usr/bin/date", 0x0004FE50, 0x00057CF8) argc = 1 $ more make-3.74/job.c /* Replace the current process with one running the command in ARGV, with environment ENVP. This function does not return. */ void exec_command (argv, envp) char **argv, **envp; { /* Be the user, permanently. */ child_access (); /* Run the program. */ environ = envp; execvp (argv[0], argv); switch (errno) { case ENOENT: error ("%s: Command not found", argv[0]); break; case ENOEXEC: { /* The file is not executable. Try it as a shell script. */ extern char *getenv (); char *shell; char **new_argv; int argc; shell = getenv ("SHELL");