Why is the output of Device Status Report sent to the standard input instead of output?
5
votes
7
answers
808
views
On Wikipedia [it is explained](https://en.wikipedia.org/wiki/ANSI_escape_code) that "Device Status Report" is an ANSI control sequence that "[r]eports the cursor position (CPR) by transmitting
ESC[n;mR
, where n
is the row and m
is the column".
So, in MATE Terminal, in Bash, if I do
echo -ne '\e[6n'
then I get ;1R
. It looks like a part of the response that Wikipedia describes. If I then add read
like
echo -ne '\e[6n' ; read
then I get ^[[2;1R
. I have it where I would expect to provide input. I conclude that this is the proper output of Device Status Report, and that it is being sent to the standard input.
**What are the reasons that it is sent to the standard input and not output?**
I find this behavior unintuitive. If I would like to know the position of the cursor, ideally I'd have it on the standard output. Like, I could then assign it to a variable easily. Does it play a role that the control sequence is called "Device Status Report" and not "Cursor Position Report"?
I see there are multiple questions here regarding Device Status Report, but I cannot find any that would answer this question. If there is, I'd appreciate a link.
Asked by decision-making-mike
(179 rep)
Jul 16, 2025, 11:48 PM
Last activity: Jul 19, 2025, 06:41 PM
Last activity: Jul 19, 2025, 06:41 PM