开发者

Show and execute

In this makefile

dirs = $(shell ls)
clean:
    $(foreach dir,$(dirs),echo $(dir);)

The output is

$ make clean
echo bin; echo install.sh; echo Makefile; echo README.md; echo utils;
bin
install.sh
Makefile
README.md
utils

Why does it first show the command, then execut开发者_如何学编程e it? How I can omit the first line?


Prepend the command with the @ character. Example:

dirs = $(shell ls)
clean:
    @$(foreach dir,$(dirs),echo $(dir);)


From the manual (5.2 Recipe Echoing, bold emphasis mine):

Normally make prints each line of the recipe before it is executed. We call this echoing because it gives the appearance that you are typing the lines yourself.

When a line starts with @, the echoing of that line is suppressed. The @ is discarded before the line is passed to the shell. [...]


Alternatively:

The -s or --silent flag to make prevents all echoing, as if all recipes started with @.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜