ONESHELL adding to SHELLFLAGS when it contains =

Mohammad Akhlaghi <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
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: $@"
Makefile (text/plain, 83 B)
SHELL:=$(shell pwd)/testscript.sh
.ONESHELL:
.SHELLFLAGS := --abc=4
all:
	echo def
testscript.sh (application/x-shellscript, 21 B)
echo "arguments: $@"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.