Skip to content

Piping Text To An External Program Appends A Trailing Newline #5974

@ThePieMonster

Description

@ThePieMonster

Steps to reproduce

Run the below command in Linux, Command Prompt, and PowerShell and compare the output.

echo -n "string" | openssl dgst -sha256 -hmac "authcode"

I also attempted to change the encoding PowerShell was using to UTF-8 but that did not change the value of the returned hash.

[Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8

Expected behavior

Linux/CMD Response: (stdin)= 54ef1d2effbc663eb6dc84a49cc1600b30e79f2e1ff737b99cd96589842d50e9
PowerShell Response:(stdin)= 54ef1d2effbc663eb6dc84a49cc1600b30e79f2e1ff737b99cd96589842d50e9

Actual behavior

Linux/CMD Response: (stdin)= 54ef1d2effbc663eb6dc84a49cc1600b30e79f2e1ff737b99cd96589842d50e9
PowerShell Response:(stdin)= 08daf0944f91c2d904ef9f231c4e767067c9b795197c4fe46631aa78c7e9d0c4

Environment data

> $PSVersionTable
Name                           Value                                                                                       
----                           -----                                                                                       
PSVersion                      5.1.16299.98                                                                                
PSEdition                      Desktop                                                                                     
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                     
BuildVersion                   10.0.16299.98                                                                               
CLRVersion                     4.0.30319.42000                                                                             
WSManStackVersion              3.0                                                                                         
PSRemotingProtocolVersion      2.3                                                                                         
SerializationVersion           1.1.0.1                                                                                     

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-By DesignThe reported behavior is by design.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions