linux try-run分析

来源:互联网 发布:网络销售彩票诈骗流程 编辑:程序博客网 时间:2024/05/02 20:50

文件scripts/Kbuild.include中:


TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)

try-run = $(shell set -e; \

TMP="$(TMPOUT).$$$$.tmp";\
TMPO="$(TMPOUT).$$$$.o";\
TMPSU="$(TMPOUT).$$$$.su";\
if ($(1)) >/dev/null 2>&1;\
then echo "$(2)";\
else echo "$(3)";\
fi; \

rm -f "$$TMP" "$$TMPO" "$$TMPSU")

分析:

bash Conditional Constructs :

if test-commands; then
consequent-commands;
[elif more-test-commands; then
more-consequents;]
[else
alternate-consequents;]
fi


If test-commands returns a non-zero
status, each
elif list is executed in turn, and if its exit status is zero, the
corresponding
more-consequents is executed and the command completes.

if ($(1)) >/dev/null 2>&1;

test-commands 是 ($(1)) >/dev/null 2>&1,执行$(1)即第一个参数中的语句,标准输出和标准错误输出到/dev/null;

如果执行成功返回第二个参数,否则返回第三个参数。



0 0
原创粉丝点击