[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Masahiro Yamada
Subject: [bug #55720] Make cannot execute shell-builtin commands in recipe
Date: Sat, 16 Feb 2019 05:11:06 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/71.0.3578.98 Chrome/71.0.3578.98 Safari/537.36


                 Summary: Make cannot execute shell-builtin commands in recipe
                 Project: make
            Submitted by: masahiroy
            Submitted on: Sat 16 Feb 2019 10:11:05 AM UTC
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: None
        Operating System: None
           Fixed Release: None
           Triage Status: None



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

They work in the same way:

$ which gcc
$ command -v 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
$ 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

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

Is this a bug that should be fixed?


File Attachments:

Date: Sat 16 Feb 2019 10:11:05 AM UTC  Name: Makefile  Size: 189B   By:



Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]