Confusion about $(shell) call and quoting

[email protected]
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
Hello list

Given this directory structure

$ tree .
.
|-- D
|   |-- f1.png
|   `-- f2.png
|-- Makefile
`-- img.png

1 directory, 4 files

and this makefile

$ cat Makefile
PNGS := $(shell find D -name '*.png' -type f)

all : tellpng

.PHONY : tellpng
tellpng :
	echo pngs: $(PNGS)

running make give this output

$ make
echo pngs:
pngs:

I was hoping to see the two png files in the D directory. If I change
to

PNGS := $(shell find D -name "*.png" -type f)

(using double quotes) the two png files in the D directory are found.

Running make with the -d option I see the following differences of the
CreateProcess call using single quotes, no quotes and double quotes
around the -name argument (*.png), (editing the makefile).

With single quotes:
CreateProcess(C:\progs\Git\usr\bin\find.exe,find D -name *.png -type 
f,...)

With no quotes:
CreateProcess(C:\progs\Git\usr\bin\sh.exe,C:/progs/Git/usr/bin/sh.exe -c 
"find D -name *.png -type f",...)

With double quotes:
CreateProcess(C:\progs\Git\usr\bin\sh.exe,C:/progs/Git/usr/bin/sh.exe -c 
"find D -name \"*.png\" -type f",...)

In the first example (with single quotes), it looks as if find is
called directly, and not shell?

Should I learn from this that its better to use double quotes in a
$(shell) call like this, or is there something strange going on?

The make run here is the ezwinports make,

$ make --version
GNU Make 4.3
Built for Windows32
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

What do you think?

--
Tomas
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.