我应该向 STDERR 还是 STDOUT 输出警告?

编程入门 行业动态 更新时间:2024-10-16 02:29:11
本文介绍了我应该向 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 输出警告?

本文发布于:2023-06-11 14:52:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/637071.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:STDERR   STDOUT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!