help-make
[Top][All Lists]
Advanced

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

Confusion about $(shell) call and quoting


From: tomasn
Subject: Confusion about $(shell) call and quoting
Date: Tue, 16 May 2023 13:27:14 +0000

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



reply via email to

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