如何在Makefile中运行子Shell脚本? [英] How to run sub Shell script in Makefile?
本文介绍了如何在Makefile中运行子Shell脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想执行Shell命令,但是我不知道如何在我的Makefile中正确执行sub bash命令
I want to execute a Shell command but I didn't know how to do a sub bash command correctly in my Makefile
import-bd:
@while ! nc -z $(make ips | awk '/mysql/ { print $2 }') 3306; do \
sleep 1 \
done
...
感谢您的帮助!
推荐答案
您需要引用$
并添加;
import-bd:
@while ! nc -z $$(make ips | awk '/mysql/ { print $$2 }') 3306; do \
sleep 1; \
done
当make看到单个$
时,它将尝试进行变量扩展.通过编写$$
,make将单个$
传递给awk(或更准确地说,将单个$
传递给调用awk
的SHELL).另外,需要使用sleep 1
后的分号,因为make会删除换行符.
When make sees a single $
, it tries to do a variable expansion. By writing $$
, make passes a single $
to awk (or, more precisely, it passes a single $
to SHELL which invokes awk
). Also, the semi-colon after sleep 1
is needed because make strips the newline.
这篇关于如何在Makefile中运行子Shell脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文