bug-make
[Top][All Lists]
Advanced

[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

URL:
  <https://savannah.gnu.org/bugs/?55720>

                 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

    _______________________________________________________

Details:

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?




    _______________________________________________________

File Attachments:


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

<http://savannah.gnu.org/bugs/download.php?file_id=46278>

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55720>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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