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

Running the hello.com tutorial compiled in WSL2 in a CMD.exe prompt on Windows 10 corrupts it #60

Closed
spullara opened this issue Feb 26, 2021 · 4 comments
Assignees

Comments

@spullara
Copy link

After you run it, you can no longer use the arrow keys to go to the previous command, instead it prints the control characters: ^[[A

@lduguid
Copy link

lduguid commented Feb 26, 2021

After you run it, you can no longer use the arrow keys to go to the previous command, instead it prints the control characters: ^[[A

same issue on my machine. build on WSL2, run in WSL2 - OK, run in win32 CMD.exe - as above.

@alisonatwork
Copy link
Contributor

alisonatwork commented Feb 26, 2021

A temporary workaround for this is to run in a Powershell console, where this doesn't happen, or just run CHCP 437 after running the APE binary. It seems like it's not resetting the code page after changing it to 65001 (UTF-8) in https://github.com/jart/cosmopolitan/blob/master/libc/runtime/winmain.greg.c.

See also https://ss64.com/nt/chcp.html for more on CHCP.

Edit to add: actually, it seems you can just run CHCP with no arguments to stay in UTF-8 code page, but somehow this resets the console state so that arrow keys work again 🤷

@spullara
Copy link
Author

It looks like we ought to grab the codepage at the beginning and then restore it on exit. I'll take a look at doing that and see if that is what is causing it. It worries me that it got fixed without resetting the codepage. Maybe there is something else that needs to be reset.

@jart jart self-assigned this Feb 27, 2021
@jart jart closed this as completed in 35c7eda Feb 27, 2021
@jart
Copy link
Owner

jart commented Feb 27, 2021

Thanks for the report. It seems what was happening is that the virtual processing terminal mode was persisting across processes. I've now fixed things so that exit() will restore the console mode. You can download the latest binaries here: https://justine.lol/redbean/index.html and https://justine.lol/cosmopolitan/download.html

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

No branches or pull requests

4 participants