Date: Mon, 14 Aug 1995 18:54:50 +0200 From: Wolfram Schneider <wosch@cs.tu-berlin.de> To: Garrett Wollman <wollman@halloran-eldar.lcs.mit.edu> Cc: current@freebsd.org Subject: make(1) extension for SHELL COMMANDS Message-ID: <199508141654.SAA16905@caramba.cs.tu-berlin.de> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508141654.SAA16905>
