[英]How do I get a `Pipe` to the standard input/output/error in Swift?
When using Process
in Swift, if you do not specify the .standardInput
, .standardOutput
, or .standardError
properties, the Process
inherits the standard input/output/error of the caller, which can be quite useful.在 Swift 中使用Process
时,如果不指定.standardInput
、 .standardOutput
或.standardError
属性,则Process
会继承调用者的标准输入/输出/错误,这非常有用。 But let's say that, for example, I want to tell a Process
to send its output to the inherited standard error.但是假设,例如,我想告诉Process
将其 output 发送到继承的标准错误。 It seems to me I would want to do something like process.standardOutput = ProcessInfo.processInfo.standardError
, but ProcessInfo
has no standardError
property.在我看来,我想做类似process.standardOutput = ProcessInfo.processInfo.standardError
的事情,但ProcessInfo
没有standardError
属性。 How am I supposed to do something like this?我该怎么做这样的事情?
Of course I find the answer to this immediately after posting this question.当然,我在发布此问题后立即找到了答案。
The desired objects are FileHandle.standardInput
, FileHandle.standardOutput
, and FileHandle.standardError
.所需的对象是FileHandle.standardInput
、 FileHandle.standardOutput
和FileHandle.standardError
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.