help-make
[Top][All Lists]
Advanced

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

ONESHELL adding to SHELLFLAGS when it contains =


From: Mohammad Akhlaghi
Subject: ONESHELL adding to SHELLFLAGS when it contains =
Date: Mon, 29 May 2023 17:59:56 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2

Hello,

I was testing with giving a custom 'SHELL' to GNU Make, and noticed that '.ONESHELL' and '.SHELLFLAGS' can conflict when '.SHELLFLAGS' has an '='.

Let me demonstrate it with the minimal working example Makefile and shell script that are attached (and included in the P.S.).

When I put these two files are placed in the same directory, and run GNU Make 4.4.1, I get the following output:

$ make
echo def
arguments: --abc 4 echo def

However, when I change the 'SHELLFLAGS' to '--abc=4'

$ make
echo def
arguments: /bin/sh -c abc=4 echo def

As you see, Make places a '/bin/sh -c' before the arguments that it passes to the shell.

If I use the original 'SHELLFLAGS', but comment the 'ONESHELL' line, this doesn't happen any more (the '=' sign does not cause the extra arguments).

I wanted to check if this is an expected feature or if this is a bug? I couldn't find anything in the "Choosing the shell" section of the documentation that describes 'SHELLFLAGS':

https://www.gnu.org/software/make/manual/html_node/Choosing-the-Shell.html

Cheers,
Mohammad





P.S. Sources of the two demonstration files.

$ cat Makefile
SHELL:=$(shell pwd)/testscript.sh
.ONESHELL:
.SHELLFLAGS := --abc 4
all:
        echo def

$ cat testscript.sh
echo "arguments: $@"

Attachment: Makefile
Description: Text document

Attachment: testscript.sh
Description: application/shellscript


reply via email to

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