我/bin/sh: -c: line 1: syntax error: unexpected end of file在下面的makefile中获得if语句-怎么了?(我的提示是/tmp >。)
/tmp > make test
set -e
if [[ -f /tmp/device ]] ; then
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [test] Error 2
/tmp > cat Makefile
.ONESHELL:
test:
set -e
if [[ -f /tmp/device ]] ; then
echo 'Do something'
fi
Run Code Online (Sandbox Code Playgroud)
我正在使用GNU Make 3.81。
使用GNU Make 3.81时,该.ONESHELL功能显然不受支持-您已经证明了,而我已经证明了。我在Mac OS X 10.11.5上进行了测试,提供的/usr/bin/make是GNU Make 3.81。我通过在其echo PID=$$$$之前set -e,之后等添加策略性放置的行来表示满意,并观察到不同的PID值。GNU Make版本3.81是2006年的版本(2010年还有版本3.82,在版本4.x发行之前,从2013年的4.0开始)。
GNU Make的当前版本是4.2.1(2016年6月)。该版本确实支持该功能。使用最新版本的GNU Make时,脚本可以按预期工作。该功能已经存在了一段时间-您可能不必升级到最新版本即可获得支持,但是如果仍然要升级,为什么还要选择降级版本。
如果要使用该.ONSHELL:功能,则必须确保使用了足够新的GNU Make版本(比3.81版本更新)。如果那不可行,请不要使用该功能。
从4.2.1读取NEWS文件,很明显它ONESHELL已添加到GNU Make版本3.82:
Run Code Online (Sandbox Code Playgroud)Version 3.82 (28 Jul 2010) … * New special target: .ONESHELL instructs make to invoke a single instance of the shell and provide it with the entire recipe, regardless of how many lines it contains. As a special feature to allow more straightforward conversion of makefiles to use .ONESHELL, any recipe line control characters ('@', '+', or '-') will be removed from the second and subsequent recipe lines. This happens _only_ if the SHELL value is deemed to be a standard POSIX-style shell. If not, then no interior line control characters are removed (as they may be part of the scripting language used with the alternate SHELL).
| 归档时间: |
|
| 查看次数: |
479 次 |
| 最近记录: |