bugmake - Bugs: bug #55720, Make cannot execute shell-builtin...

 
 

bug #55720: Make cannot execute shell-builtin commands in recipe

Submitted by:  Masahiro Yamada <masahiroy>
Submitted on:  Sat 16 Feb 2019 10:11:05 AM UTC  
 
Severity:  3 - Normal Item Group:  Enhancement
Status:  Fixed Privacy:  Public
Assigned to:  Paul D. Smith <psmith> Open/Closed:  Closed
Component Version:  4.2.1 Operating System:  POSIX-Based
Fixed Release:  4.3 Triage Status:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 17 Feb 2019 01:06:20 AM UTC, comment #1: 

I take back this report.

I was using a released version.
The git version is fine.

This issue was fixed by the following commit.

commit 1af314465e5dfe3e8baa839a32a72e83c04f26ef
    * job.c: Add "command" as a known shell built-in.

Sorry for noise.

Masahiro Yamada <masahiroy>
Sat 16 Feb 2019 10:11:05 AM UTC, original submission:  

To print the install path of a command,
you can use 'which', 'command -v', etc.

They work in the same way:

$ which gcc
/usr/bin/gcc
$ command -v gcc
/usr/bin/gcc

'command' is included in POSIX, but 'which' is not.

So, if you want to write as portable code as possible
you may prefer 'command -v'.

However, 'command -v' does not work in Makefile
because it is a shell-builtin command.

People generally expect recipe lines are executed in a shell.
In fact, Make skips spawning a shell for optimization in some cases.

Beginners who are unfamiliar with this Make-internal may wonder why.

I attached a test Makefile.

$ make all
which gcc
/usr/bin/gcc
$ make all2
command -v gcc
make: command: Command not found
Makefile:6: recipe for target 'all2' failed
make: *** [all2] Error 127
$ make all3
: ~; command -v gcc
/usr/bin/gcc

$(shell command -v gcc) does not work either.
Probably for the same reason.

Is this a bug that should be fixed?

Masahiro Yamada <masahiroy>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #46278:  Makefile added by masahiroy (189B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Updated the item)
  • -email is unavailable- added by masahiroy (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-05-13 psmith Item GroupNone => Enhancement
        StatusNone => Fixed
        Assigned toNone => psmith
        Open/ClosedOpen => Closed
        Component VersionNone => 4.2.1
        Operating SystemNone => POSIX-Based
        Fixed ReleaseNone => 4.3
    2019-02-16 masahiroy Attached File- => Added Makefile, #46278

    Back to the top


    Powered by Savane 3.7