microsoft / microsoft/WSL

When calling native application, carriage return `\r` in the output should be removed

Open
#7,248 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

Is your feature request related to a problem? Please describe.

When calling a native application, such as powershell.exe, carriage return \r is retained, causing problem down the pipeline.

$ result=$(powershell.exe "Write-Output test")
$ python3 -c "import sys; print(sys.argv)" "$result"
['-c', 'test\r']

The actual output of powershell.exe contains \r\n, but WSL only removes \n, leaving \r in the output.

Describe the solution you'd like

WSL should be smart enough to remove \r.

Additional context

This causes failure when calling Azure CLI installed on Windows (C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd) from WSL (https://github.com/Azure/azure-cli/issues/13573#issuecomment-888791313).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the powershell.exe command from the issue and inspect where WSL handles native application output and strips line endings. Done means carriage returns from CRLF output are removed in command substitution while the existing newline behavior remains correct; the issue does not name a source file or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, powershell
Domain
cli, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.