Powershell and command line used in the pipe "|" inconsistent results #17178

Closed
opened 2026-01-31 05:34:26 +00:00 by claunia · 3 comments
Owner

Originally created by @ljxqc on GitHub (Apr 7, 2022).

Windows Terminal version

1.12.10733.0

Windows build number

10.0.22593.1

Other Software

openssl 3.0.1

Steps to reproduce

Run the openssl command to obtain the web remote certificate(use pipe "|"):

openssl s_client -connect www.baidu.com:443 -servername www.baidu.com | openssl x509 -pubkey -nout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64

Expected Behavior

image

Actual Behavior

image

Originally created by @ljxqc on GitHub (Apr 7, 2022). ### Windows Terminal version 1.12.10733.0 ### Windows build number 10.0.22593.1 ### Other Software openssl 3.0.1 ### Steps to reproduce Run the openssl command to obtain the web remote certificate(use pipe "|"): > openssl s_client -connect www.baidu.com:443 -servername www.baidu.com | openssl x509 -pubkey -nout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64 ### Expected Behavior ![image](https://user-images.githubusercontent.com/72794384/162246162-37f98b43-0333-473c-bb9d-89583e12f9eb.png) ### Actual Behavior ![image](https://user-images.githubusercontent.com/72794384/162246229-65e8068d-d672-456f-ba91-4a57fe5e6f7a.png)
claunia added the Issue-BugResolution-ExternalNeeds-Tag-Fix labels 2026-01-31 05:34:26 +00:00
Author
Owner

@lhecker commented on GitHub (Apr 7, 2022):

PowerShell doesn't work like traditional shells and doesn't support "raw pipes" between processes like under UNIX (or cmd.exe). When you write a pipe | in PowerShell, it'll transform the output into objects and give it some meaning.

So for instance if you write this:

Get-ChildItem | Get-Content

Get-ChildItem returns a Object[], where each Object is actually a instance of DirectoryInfo. It doesn't transmit "text" at all!

Since PowerShell only supports objects and not raw text, it's thus forced to turn any and all application output in some form of object. For instance try running this:

(openssl version).GetType()

Since version prints a single line, PowerShell will turn it into a String object.

If you run something that prints many lines it'll turn it into an array of Strings:

(openssl genrsa).GetType()

This means your openssl dgst -sha256 -binary will not work, because it outputs binary data, which isn't valid UTF8 text. PowerShell only accepts valid Strings though and will thus discard some of your raw binary data. I think you should check out https://github.com/PowerShell/PowerShell/issues/1908. 🙂

I'm personally not particularly happy about this behavior either, but it definitely isn't a fault in Windows Terminal and a fix seems to be in the near term roadmap.

/dup https://github.com/PowerShell/PowerShell/issues/1908

@lhecker commented on GitHub (Apr 7, 2022): PowerShell doesn't work like traditional shells and doesn't support "raw pipes" between processes like under UNIX (or cmd.exe). When you write a pipe `|` in PowerShell, it'll transform the output into objects and give it some meaning. So for instance if you write this: ```pwsh Get-ChildItem | Get-Content ``` `Get-ChildItem` returns a `Object[]`, where each `Object` is actually a instance of `DirectoryInfo`. It doesn't transmit "text" at all! Since PowerShell only supports objects and not raw text, it's thus forced to turn any and all application output in some form of object. For instance try running this: ``` (openssl version).GetType() ``` Since `version` prints a single line, PowerShell will turn it into a `String` object. If you run something that prints many lines it'll turn it into an array of `String`s: ``` (openssl genrsa).GetType() ``` This means your `openssl dgst -sha256 -binary` will not work, because it outputs binary data, which isn't valid UTF8 text. PowerShell only accepts valid `String`s though and will thus discard some of your raw binary data. I think you should check out https://github.com/PowerShell/PowerShell/issues/1908. 🙂 I'm personally not particularly happy about this behavior either, but it definitely isn't a fault in Windows Terminal and a fix seems to be in the near term roadmap. /dup https://github.com/PowerShell/PowerShell/issues/1908
Author
Owner

@ghost commented on GitHub (Apr 7, 2022):

Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!

@ghost commented on GitHub (Apr 7, 2022): Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!
Author
Owner

@ghost commented on GitHub (Apr 7, 2022):

Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!

@ghost commented on GitHub (Apr 7, 2022): Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17178