Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsl --list in powershell script, many unexpected space characters #4180

Closed
silverqx opened this issue Jun 18, 2019 · 5 comments
Closed

wsl --list in powershell script, many unexpected space characters #4180

silverqx opened this issue Jun 18, 2019 · 5 comments
Labels

Comments

@silverqx
Copy link

I need to wsl -l in my dotfiles, but it doesn't behave correctly, when I use this command with pipe or redirection, output looks like this:

W i n d o w s   S u b s y s t e m   f o r   L i n u x   D i s t r i b u t i o n s :


 U b u n t u   ( D e f a u l t )


 L e g a c y


 U b u n t u - t m p



I'm talking about these commands:
wsl -l | echo
wsl -l | sls ubuntu
wsl -l > file.txt

Does anybody have any idea how to workaround this problem?

@therealkenc
Copy link
Collaborator

but it doesn't behave correctly

Are you sure? Does your script parse the output if the string "(Default)" or an --import distribution name that is Kanji or Chinese text?

It's correct, just, well, unfortunate. You can probably get to where you want to be from Linux with:

$ wsl.exe -l | iconv -c -f utf16 -t utf8

From Powershell, I'm not qualified to repeat the Google hits.

@silverqx
Copy link
Author

I can leave without this wsl -l check in my script for now, but would be much helpful to mark this as a bug for later investigation, if not we can close this issue.
@therealkenc thank you for advice.

@therealkenc
Copy link
Collaborator

therealkenc commented Jun 20, 2019

It is not a bug. It is powershell's by-design behavior. And unrelated to wsl.exe, which does not output ASCII because its output is internationalized.

@riverar
Copy link

riverar commented Nov 4, 2019

As mentioned in #4607, it is unexpected that WSL outputs multi-byte codepoints. I suspect this bug was closed too hastily. It's unclear if this even went through proper triage; it doesn't appear @therealkenc works at Microsoft...

@silverqx
Copy link
Author

silverqx commented Nov 4, 2019

It doesn't work correctly in any console, powershell, cmd or conemu, the same problem.

But I tried it now and it works correctly in all consoles :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants