Rei*_*eid 7 unix shell makefile gnu-make
我有一个运行命令的makefile可能需要一段时间.如果构建是从交互式shell启动的话,我希望这些命令是健谈的,但如果没有(特别是cron)则更安静.(伪代码)的一些东西:
foo_opts = -a -b -c
if (make was invoked from an interactive shell):
foo_opts += --verbose
all: bar baz
foo $(foo_opts)
Run Code Online (Sandbox Code Playgroud)
这是GNU make.如果我所做的具体细节,我可以编辑问题.
它不是严格确定是否从交互式shell调用,但对于将输出重定向到文件的cron作业,此问题的答案与如何检测我的shell脚本是否相同正在通过管道?:
if [ -t 0 ]
then
# input is from a terminal
fi
Run Code Online (Sandbox Code Playgroud)
编辑:使用它来设置Makefile中的变量(在GNU make中,即):
INTERACTIVE:=$(shell [ -t 0 ] && echo 1)
ifdef INTERACTIVE
# is a terminal
else
# cron job
endif
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2549 次 |
| 最近记录: |