每当我调用 run GCC 时,它都会很好地格式化其输出(使文件名加粗、注释标签为白色、错误标签为红色等)。但是,当我想重定向它并仍然保持显示时,格式就消失了......
例子:
make # The display is formatted
(...)
make |& tee >(xargs echo > example.out) # The display is not formatted
(...)
如何在保持原始显示格式的同时重定向输出?
最佳答案
文档说(文件:gcc-6.info,节点:诊断消息格式化选项
):
-fdiagnostics-color
[=WHEN]Use color in diagnostics. WHEN is
never
,always
, orauto
. The default depends on how the compiler has been configured, it can be any of the above WHEN options or alsonever
ifGCC_COLORS
environment variable isn't present in the environment, andauto
otherwise.auto
means to use color only when the standard error is a terminal.
关于c++ - 我可以在处理它时保留编译器输出的格式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40767475/