2019-06-03 12:34
采纳率: 0%
浏览 111

与命令提示符相比,PowerShell如何处理重定向? [重复]

I am running a Go program that generates a file in gif format. When using Bash or Command Prompt, the file is generated successfully. However, when using PowerShell or PowerShell-Core, I receive an error: "The image ‘file:///C:\Users\blah\blah\blah’ cannot be displayed because it contains errors".

How can I generate this file correctly using PowerShell?

I have attempted to run the exact same commands that worked on Bash and Command Prompt. I have also tried using PowerShell cmdlets like Out-File and Tee-Object.

go build main.go
.\main.exe > out.gif
firefox out.gif

Performing the above actions in Bash or Command Prompt generate the file and the expected gif. Performing the action in PowerShell yields the error message described above (image cannot be displayed because it contains errors).

I have also tried:

.\main.exe | Out-File out.gif
.\main.exe | Tee-Object out.gif

Both generate the broken file.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答