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: $@"
SHELL:=$(shell pwd)/testscript.sh
.ONESHELL:
.SHELLFLAGS := --abc=4
all:
        echo def

Attachment: testscript.sh
Description: application/shellscript

Reply via email to