你好。
我想让 Arg.usage 的输出写入 stdout 而不是 stderr,又不想把整个旧程序重写一遍。我是这样试的。
Unix.dup2 Unix.stdout Unix.stderr; (* send output to stdout. *)
Arg.usage (Arg.align (hiddenhelp @ options)) “”
(程序随后就退出了,所以我想应该不需要恢复什么……)。
在 Unix 上这样能用,但在 Windows 上,stdout 和 stderr 都没有输出。Unix 文档中 dup2 的条目没有提到 Windows。
有什么建议吗?
从英语翻译·查看原文Hello.
I'd like the output produced by Arg.usage to be written to stdout rather than stderr, without having to restructure my entire older program. Here's my attempt:
Unix.dup2 Unix.stdout Unix.stderr; (* send output to stdout. *)
Arg.usage (Arg.align (hiddenhelp @ options)) “”
(The program exits afterwards, so I assume there's nothing we must restore…).
On Unix this works, but Windows produces nothing on either stdout or stderr. The entry for dup2 in the Unix documentation doesn't mention anything about Windows.
Any suggestions?