2 ms·
> When people talk about "ANSI sequences" and "ANSI conformant", they also indicate that likely their knowledge comes from old wives' tales and samizdat. Or ma
by kazinator 6y ago
> When people talk about "ANSI sequences" and "ANSI conformant", they also indicate that likely their knowledge comes from old wives' tales and samizdat.
Or maybe some of them are actually referring to ANSI X3.64.
> Not actually testing it enough to find the common case where it doesn't work gives the lie to that claim.
I happen to maintain code that outputs VT100 sequences to control the screen; it's tested on GNU/Linuxes (various emulators), Cygwin, Solaris, MacOS, FreeBSD. Plus remote terminals like PuTTY, various Android SSH clients (ConnectBot, JuiceSSH, ...). So from that and other past work I'm confident that the escape sequence (which can be found in the DEC VT100 manual) works fine in more places than I care to support.
(If the only piece of code in this area I had ever written were the above script, then of course I wouldn't be.)
The script itself isn't portable; it uses nonportable features of stty, and Bash extensions of read.
The parsing of the terminal's response is probably adequate for the intended use, and was labeled clearly as "proof of concept". It won't handle serial line noise. (Actually, nothing will do that under all conditions anyway. Even if parity is enforced, the response can be damaged in such a way that it has valid syntax, but wrong digits giving incorrect coordinates.) Virtual terminals transmit the response reliably.
If you can think of a way that a malicious terminal emulator could target and exploit the flimsy parsing, do share.
- kazinator 6y agoaddendum: real version of the code should handle decimal integers with leading zeros.