bugmake - Bugs: bug #47171, please fall back to system() when...

 
 

bug #47171: please fall back to system() when command is not found on $PATH

Submitter:  Manoj Srivastava <srivasta>
Submitted:  Tue 16 Feb 2016 08:34:37 PM UTC
   
 
Severity:  3 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  None Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 16 Feb 2016 08:34:37 PM UTC, original submission:  

Hi,

This was reported by a debian user. Please retain a CC to
 635646-forwarded@bugs.debian.org
so that the Debian BTS has a copy of your input.



Trying the following makefile:

test:
command -v ls

I get the following result:

$ make
command -v ls
make: command: Command not found
make: * [test] Error 127
$ sh -c 'command -v ls'
/bin/ls

but POSIX sayeth

| An execution line is built from the command line by removing
| any prefix characters. Except as described under the at-sign
| prefix, the execution line shall be written to the standard
| output, optionally preceded by a <tab>. The execution line |
| shall then be executed by a shell as if it were passed as the
| argument to the system( ) interface, except that the shell −e
| option shall also be in effect.

The cause is that "make" expects to be run on a POSIX system, where non-special shell builtins like "command" would be available for use by execvp (see sh_cmds[] in job.c).  See the explanation by Jilles Tjoelker at
 http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=43;bug=436466
for more details.

I can imagine two fixes, and both seem separately valuable:

 a. one hand hand, introducing a new package to provide those
    non-special builtins that are not provided by some
    pseudo-essential package (using alternatives to deal with
    alternative implementations where necessary):

#!/bin/sh
command -p ${0##*/} "$@"

 b. on the other hand, teaching "make" to handle ENOENT from
    execvp by falling back to the shell.  (The shell can print a
    message about it if that ENOENT was actually due to a
    missing shared library or interpreter.)  This way, "make"
    could even use shell builtins that are not mandated by POSIX
    when the system shell happens to implement them.

This report is about (b).  Thoughts?

  Manoj

Manoj Srivastava <srivasta>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by srivasta (Submitted the item)
  • -email is unavailable- added by srivasta (Debian BTS)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-02-16 srivasta Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code