抑制makefile中命令调用的回显? [英] Suppress echo of command invocation in makefile?

查看:213
本文介绍了抑制makefile中命令调用的回显?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为分配编写了一个程序,该程序应该将其输出打印到stdout.分配规范要求创建一个Makefile,当以make run > outputFile调用该Makefile时应运行程序并将输出写入文件,该文件的SHA1指纹与规范中给出的指纹相同.

I wrote a program for an assignment which is supposed to print its output to stdout. The assignment spec requires the creation of a Makefile which when invoked as make run > outputFile should run the program and write the output to a file, which has a SHA1 fingerprint identical to the one given in the spec.

我的问题是我的makefile文件:

My problem is that my makefile:

...
run:
     java myprogram

还会将运行我的程序(例如java myprogram)的命令打印到输出文件,以便我的文件包含多余的行,从而导致指纹错误.

also prints the command which runs my program (e.g. java myprogram) to the output file, so that my file includes this extra line causing the fingerprint to be wrong.

在不将命令调用回显到命令行的情况下,有什么方法可以执行命令?

Is there any way to execute a command without the command invocation echoing to the command line?

推荐答案

在命令开头添加@,以告知gmake不要打印正在执行的命令.像这样:

Add @ to the beginning of command to tell gmake not to print the command being executed. Like this:

run:
     @java myprogram

正如Oli所建议的,这是Make的功能,而不是Bash的功能.

As Oli suggested, this is a feature of Make and not of Bash.

另一方面,除非您明确指示Bash执行(除非使用-x选项),否则Bash绝不会回显正在执行的命令.

On the other hand, Bash will never echo commands being executed unless you tell it to do so explicitly (i.e. with -x option).

这篇关于抑制makefile中命令调用的回显?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆