Timeline for Need Help Understanding script that reads output of cursor position ANSI escape code
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 9 at 20:43 | comment | added | Barmar |
@user153064 Another related misunderstanding is using echo something > /dev/tty and then expecting to be able to read that back in with read < /dev/tty. But /dev/tty is not a loopback device -- output goes to the screen, input comes from the keyboard.
|
|
| Jul 9 at 20:38 | comment | added | user153064 | This is an awesome answer, Barmar! I've been trying to understand this process off-and-on for a couple of years, and here you come along and make it all fall into place! It never occurred to me that the reply to the ESC[6n request was being sent to input, and all I had to do was read the input. Thank you, tons! (Also thanks to Paul_Pedant, for prompting Barmar to help me also understand ^[ as one "character" instead of two.) | |
| Jul 9 at 20:32 | vote | accept | user153064 | ||
| Jul 8 at 20:05 | comment | added | Barmar | Thanks, I've added something about that. | |
| Jul 8 at 20:05 | history | edited | Barmar | CC BY-SA 4.0 |
added 192 characters in body
|
| Jul 8 at 20:01 | comment | added | Paul_Pedant | One omission from this fine answer is that the tty makes the output readable, representing it as two printable characters. It just happens that the single ESC character (octal 033) is rendered as ^[ (octal 136 133) for display purposes. The first read -s reads only one character ESC and one delimiter [. | |
| Jul 8 at 19:18 | history | answered | Barmar | CC BY-SA 4.0 |