yzo*_*org 8 powershell stderr powershell-2.0
我在 Windows 上使用 cygwin 工具的一个端口,它将正常状态消息写入 STRERR。从 PowerShell 运行时,这会产生丑陋的输出:
PS> dos2unix.exe -n StartApp.sh StartApp_fixed.sh
dos2unix.exe : dos2unix: converting file StartApp.sh to file StartApp_fixed.sh in UNIX format ...
At line:1 char:13
+ dos2unix.exe <<<< -n StartApp.sh StartApp_fixed.sh
+ CategoryInfo : NotSpecified: (dos2unix: conve...UNIX format ...:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Run Code Online (Sandbox Code Playgroud)
有没有更好的办法?
PS 我打算发布我找到的一个解决方案,并将其与其他人的答案进行比较。
这是我找到的一种解决方案。如果您有更好的答案,请发布您的答案(这仅适用于将状态消息发送到 STDERR 而不是正常输出流的命令行实用程序):
PS> $output = dos2unix.exe -n StartApp.sh StartApp_fixed.sh 2>&1
$output.CategoryInfo.TargetName | Out-Default
dos2unix: converting file StartApp.sh to file StartApp_fixed.sh in UNIX format ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12840 次 |
| 最近记录: |