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

Can't get contain '\r' input from Screen.buffer #144

Open
18853477039 opened this issue Feb 20, 2021 · 2 comments
Open

Can't get contain '\r' input from Screen.buffer #144

18853477039 opened this issue Feb 20, 2021 · 2 comments

Comments

@18853477039
Copy link

this is my debug code

`
buf = os.read(self.input.fileno(), 4096)

LOG.info(repr(buf))
`

when I send whoami by xshell's command bar
the buf's log is
[process_stdin():76] [PID:33553 TID:140554967484224] 'whoami\r'

Screen.buffer's log is
'[root@fortress-test-169fb0752 ~]#' .

If I just use the shell, input whoami
the buf's log is
[process_stdin():76] [PID:66022 TID:139634374461248] 'w'
[process_stdin():76] [PID:66022 TID:139634374461248] 'h'
[process_stdin():76] [PID:66022 TID:139634374461248] 'o'
[process_stdin():76] [PID:66022 TID:139634374461248] 'a'
[process_stdin():76] [PID:66022 TID:139634374461248] 'm'
[process_stdin():76] [PID:66022 TID:139634374461248] 'i'
[process_stdin():76] [PID:66022 TID:139634374461248] '\r'

Screen.buffer's log is
'[root@fortress-test-169fb0752 ~]# whoami'

So, how can I get the input contains '\r'?

@18853477039
Copy link
Author

I fix it by reading data from stdin, but it's a bad way because the logic is too bad. Is there a good way?

@superbobry
Copy link
Collaborator

\r instructs the terminal to do a carriage return. The only way to get it printed in the input is to escape the \ before printing it. I.e. before feeding data to the stream you could do data.replace("\r", "\\r").

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

2 participants