Package: make
Version: 3.81-7
Severity: normal

I'm not sure whether this qualifies as normal or wishlist; it depends
on how much GNU Make cares about POSIX compatibility.  In this
message, I primarily reference POSIX:2001.

POSIX says, regarding make(1):
| Command execution shall be as if the makefile command line were the
| argument to the system() function.

Regarding system(3):
| The environment of the executed command shall be as if a child process
| were created using fork(), and the child process invoked the sh
| utility using execl() as follows:
| 
| execl(<shell path>, "sh", "-c", command, (char *)0);
| 
| where <shell path> is an unspecified pathname for the sh utility.

sh -c has no special rules for builtins as opposed to other commands.
I interpret this to mean that a command in a Makefile is allowed to
contain a single shell builtin invocation, and that this should invoke
the builtin.

Creating a file "type.mk" with the contents:

----------------------------------------
.POSIX:
all:
        type ls
----------------------------------------

(with the first character on line 3 being a tab) results in:

----------------------------------------
$ make -f ~/tmp/type.mk
type ls
make: type: Command not found
make: *** [all] Error 127
----------------------------------------

Adding any shell metacharacters causes the shell to be invoked, and
then the "type" command succeeds properly.  Many builtins also have
associated executables, but this is not required for all builtins.

What to do about this is unclear.  I don't see any way to turn off the
heuristic other than by working around it with useless metacharacter-y
clauses in the Makefile.  Possibly detecting the .POSIX target and
turning it off then would be suitable, or possibly giving the shell a
second try iff a command is not found directly for exec(3) purposes,
though the latter still changes the priority between executables and
shell builtins.

   ---> Drake Wilson

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.29-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages make depends on:
ii  libc6                         2.10.2-2   GNU C Library: Shared libraries

make recommends no packages.

Versions of packages make suggests:
ii  make-doc                      3.81-5     Documentation for the GNU version 

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to