从 Makefile 执行 shell 脚本时出现问题
Makefile:
$(shell ./test.sh)
第一个实验:test.sh
echo "hi"
我得到的错误:
Makefile:1: *** missing separator. Stop.
第二个实验: 我得到的test.sh
echo("hi")
错误:
./test.sh: line 1: syntax error near unexpected token `"hi"'
./test.sh: line 1: `echo("hi")'
没有任何意义...看起来好像“Make”试图将其语法强加于 shell 脚本,但 shell 脚本也需要自己的语法。
Makefile:
$(shell ./test.sh)
1st experiment: test.sh
echo "hi"
Error I get:
Makefile:1: *** missing separator. Stop.
2nd experiment:
test.sh
echo("hi")
Errors I get:
./test.sh: line 1: syntax error near unexpected token `"hi"'
./test.sh: line 1: `echo("hi")'
Doesn't make any sense...it looks as if 'Make' tries to impose its syntax on the shell script, but the shell script wants its own too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
./test.sh
。在第一个实验中,结果是
当您运行
make
时,$(shell ./test.sh)
行的计算结果为hi
,这Make不知道如何解释。在第二个实验中,
您编写的 shell 脚本没有正确的 shell 语法,因此失败了。无论您运行它还是Make 运行它,它都会失败。
try
./test.sh
.In the first experiment, the result is
When you run
make
, the line$(shell ./test.sh)
evaluates ashi
, which Make doesn't know how to interpret.In the second experiment,
You've written a shell script that doesn't have correct shell syntax, so it fails. It fails whether you run it or Make runs it.