wsl --help returns one character per line when piped
Windows Version
Microsoft Windows [Version 10.0.26100.4349]
WSL Version
WSL version: 2.5.7.0 Kernel version: 6.6.87.1-1 WSLg version: 1.0.66 MSRDC version: 1.2.6074 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.26100.1-240331-1435.ge-release Windows version: 10.0.26100.4349
Are you using WSL 1 or WSL 2?
- [x] WSL 2
- [ ] WSL 1
Kernel Version
6.6.87.1-1
Distro Version
Ubuntu 24.04
Other Software
No response
Repro Steps
wsl --help cannot be piped (properly) to any program. If you run wsl --help | more you will get one character per line). Running wsl --help | grep also fails because... well, you're getting one character per line
Expected Behavior
wsl --help should return the same output format when piped and when not piped.
Actual Behavior
One character per line
Diagnostic Logs
No response
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here
Once completed please upload the output files to this Github issue.
Click here for more info on logging If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.
The log file doesn't contain any WSL traces. Please make sure that you reproduced the issue while the log collection was running.
Diagnostic information
.wslconfig found
Detected appx version: 2.5.7.0
Found no WSL traces in the logs
It isn't possible to attach logs for this issue because wsl --help can only be run outside it.
@cowwoc: This is unfortunately a known issue, because the 'Windows' part of wsl.exe outputs unicode bytes by default.
If you want to read utf8 from WSL, you can do:
set WSL_UTF8=1
wsl --help | more
Sadly this can't be the default, because it would break existing programs / scripts.
@OneBlue I'm a bit confused by this. All other Windows programs work properly with more and wsl cannot be invoked from within wsl, so why is its default behavior this way? What other Windows program works this way?
@cowwoc: That's how wsl.exe originally worked, so other programs (like docker, vscode, ...) have a taken a dependency on it, which is why we can't easily change it.
WSL_UTF8 is available for situations where you want wsl.exe to output UTF8
Okay :( I guess it is what it is. I'll go ahead and close this issue.