【发布时间】:2018-10-05 16:18:43
【问题描述】:
我有以下代码 sn-p 并且无法弄清楚为什么它不起作用:
test-%:
# this works
case $* in a) echo A;; b) echo B;; esac
# this doesn't
$(eval MY_VAR := \
$(shell case $* in a) echo A;; b) echo B;; esac ))
echo $(MY_VAR)
输出:
$ make test-a
bash: -c: line 2: syntax error: unexpected end of file
case a in a) echo A;; b) echo B;; esac
A
echo B;; esac ))
bash: -c: line 0: syntax error near unexpected token `;;'
bash: -c: line 0: `echo B;; esac ))'
makefile:277: recipe for target 'test-a' failed
make: *** [test-a] Error 1
我怀疑我需要转义一些字符,但我不知道是哪个。我尝试了 \) ,它修复了 vim 中的语法突出显示,但仍然不起作用。
【问题讨论】:
标签: shell makefile switch-statement gnu-make