This is my Makefile.
MYPATH = /dir 1/file 1.txt
test1:
echo $(notdir $(MYPATH))
test2:
echo $(notdir "$(MYPATH)")
test3:
echo TODO
My intention is to get just the file 1.txt
portion of the path from
/dir 1/file 1.txt
. Yes, this is a path with spaces in it.
I am unable to get the desired results.
$ make test1
echo dir file 1.txt
dir file 1.txt
In the above output, it appears that notdir
was provided three separate
arguments: /dir
, 1/file
and 1.txt
and as a result their notdir
parts were returned: dir
, file
and 1.txt
.
The following does not work at all.
$ make test2
echo dir file 1.txt"
/bin/sh: 1: Syntax error: Unterminated quoted string
Makefile:7: recipe for target 'test2' failed
make: *** [test2] Error 2
Why does it complain about "Unterminated quoted string"?
What is the right way to solve the problem. I want an output like the following.
$ make test3
echo file 1.txt
file 1.txt