我有这个 Makefile:
VAR=foo(1).txt foo(2).txt
foobar: $VAR
cp -p $^ foo/
当我运行它时,我收到此错误:
$ make test
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `cp -p foo(1).txt foo(2).txt foo/'
Makefile:3: recipe for target 'foobar' failed
make: *** [test] Error 1
如何快速摆脱它?
最佳答案
您可以将文件名用双引号引起来
cp "foo(1).txt" "foo(2).txt" /out
测试
$ cp "foo(1).txt" "foo(2).txt" out/
$ ls out/
foo(1).txt foo(2).txt
或者更安全
cp 'foo(1).txt' 'foo(2).txt' out/
关于bash - 如何转义 Makefile 中 cp 命令的括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27111040/