本文介绍了我应该向 STDERR 还是 STDOUT 输出警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个脚本来处理一组预定义的数据,并输出到一个文件.当一个数据(在我有权访问的每个集合中始终为常规")不同时,我想弹出一个警告,指出该值未处理(因为我不知道它如何影响数据).我应该将此警告输出到 stderr 还是 stdout?

I'm making a script that handles a predefined set of data, outputting to a file. I want to pop up a warning when one datum (which is always "Regular" in every set that I've had access to) is different stating that this value is unhandled (since I don't know how it affects the data). Should I output this warning to stderr or stdout?

推荐答案

如果我保存了这个脚本的输出(即仅限 stdout)以便我以后可以处理它,那么该警告会干扰输出的解析方式吗?此外,如果输出通过管道传输到另一个进程,则警告应显示在终端上,以便用户立即看到.

If I saved the output of this script (i.e. stdout only) so that I could process it later, would that warning interfere with how the output is parsed? Moreover, if output is piped to another process, the warning should show up on the terminal, so the user sees it immediately.

出于这些原因,通常您会向 stderr 输出警告.

For those reasons, in general, you output warnings to stderr.

这篇关于我应该向 STDERR 还是 STDOUT 输出警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 05:42