4 ms·
You'll need to install windows-curses, since cmd.exe didn't support vt100 escape sequences until relatively recently, and still requires a special WinRT call in
by freeone3000 6y ago
You'll need to install windows-curses, since cmd.exe didn't support vt100 escape sequences until relatively recently, and still requires a special WinRT call in order to enable them.
But it's a bit telling that the first hurdle you hit in running python on windows was the operating systems choosing different forty-year-old terminal emulator escape sequences. :)
- pjmlp 6y agoWindows Terminal is the actual solution.
- DHowett 6y ago"still requires a special WinRT call in order to enable them" Which WinRT call would that be? Hi, owner of the Windows Console here. Enabling VT control sequences is a matter of setting the ENABLE_VIRTUAL_TERMINAL_PROCESSING mode on the output handle, and it's available through the same interface as every console mode flag that came before it. SetConsoleMode has a long history--dating back to the nineties--that this just builds on. It's behind a flag so that applications developed before ca. 2015 that like to emit control characters to the screen don't melt away into gibberish.
- freeone3000 6y agoYes, that'd be the call in question; it requires cross-platform vt100 apps to specifically know about and call a feature on windows in order to enable it. They can't just emit control characters to terminal, they must call this WinRT function first. This isn't something you can fix, for the reasons you listed, but it's something that's true. As a side note, Windows Terminal (the app) is absolutely fine letting programs emit and handle VT100 escapes without them issuing any particular opt-in call themselves... And upon looking, you're the person who enabled this feature! Thanks for that, but, why is it good for terminal but bad for conhost?
- DHowett 6y agoSorry, I had my Microsoft-colored glasses on. We use WinRT almost exclusively to refer to the new COM-based API surface that “modern” applications use. I see now that I’ve misunderstood you :) Back when VT parsing was implemented, it was an entirely new output stream parser built into a console that hadn’t been updated in a rather long time. We were careful commensurate with its age, and opt-in made sense. Language runtimes or compatibility layers like Cygwin could handle the decision for all of their hosted applications(1) and everything else would generally continue working properly. Now that we’re working on conhost’s replacement, we get to revisit some of those decisions! Cases like this are especially acceptable because a user can always fall back to conhost. That escape hatch isn’t one we intend to get rid of. 1) this doesn’t do anything for manual or direct ports, and Cygwin is far from the only provider here. Representative example, etc.
- phkahler 6y agoThanks. I wonder why the python module instructions didnt just say to do that. Must not be widely known?
- jodrellblank 6y agoGood thing Linux users are dragging Windows back to, checks notes, 1978. https://en.wikipedia.org/wiki/VT100 https://en.wikipedia.org/wiki/VT100 Defeating 37 years of separating content from presentation https://en.wikipedia.org/wiki/Separation_of_content_and_presentation https://en.wikipedia.org/wiki/Separation_of_content_and_pres... (LaTeX) So we can embedd garbage in strings again! Causing effects like this: https://github.com/PowerShell/PowerShell/issues/13071 https://github.com/PowerShell/PowerShell/issues/13071 "On Linux, if you use ls --color then different file types use ANSI escape sequences as color indicators. If you pipe this output to less, then you get paging while retaining the color information. If you redirect this output to a file, that file contains the ANSI escape sequences. If you then use the cat command on the file, you see the coloring as the ANSI escape sequences are rendered by the terminal." Interpreting commands from log messages! Because we haven't learned from history: https://en.wikipedia.org/wiki/SQL_injection https://en.wikipedia.org/wiki/SQL_injection A glorious future awaits.
- dragonwriter 6y agoSQL and VT100 have rather different capabilities.
- jodrellblank 6y agoinb4 the first discovery of a program which "doesn't log plain text passwords" by logging them with the foreground colour set to the background color. And then the one which exploits a terminal for arbitrary command execution with a buffer overflow in the VT escape code parser. Wait, what am I talking about "inb4", that happened already and it didn't even need a buffer overflow: https://www.proteansec.com/linux/blast-past-executing-code-terminal-emulators-via-escape-sequences/ https://www.proteansec.com/linux/blast-past-executing-code-t... > "mod_rewrite.c in the mod_rewrite module in the Apache HTTP Server 2.2.x before 2.2.25 writes data to a log file without sanitizing non-printable characters, which might allow remote attackers to execute arbitrary commands via an HTTP request containing an escape sequence for a terminal emulator."
- majkinetor 6y ago> Good thing Linux users are dragging Windows back to, checks notes, 1978. Indeed, there are some non-millennial shenanigans here.