这是我的 Makefile。
MYPATH = /dir 1/file 1.txt
test1:
echo $(notdir $(MYPATH))
test2:
echo $(notdir "$(MYPATH)")
test3:
echo TODO
Run Code Online (Sandbox Code Playgroud)
我的目的是仅获取file 1.txt来自 的路径的一部分
/dir 1/file 1.txt。是的,这是一条有空格的路径。
我无法得到想要的结果。
$ make test1
echo dir file 1.txt
dir file 1.txt
Run Code Online (Sandbox Code Playgroud)
在上面的输出中,似乎notdir提供了三个单独的参数:/dir、1/file和1.txt,因此notdir
返回了它们的部分:dir、file和1.txt。
以下根本不起作用。
$ 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
Run Code Online (Sandbox Code Playgroud)
为什么它抱怨“未终止的引号字符串”?
解决问题的正确方法是什么。我想要如下的输出。
$ make test3
echo file 1.txt
file 1.txt
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3333 次 |
| 最近记录: |