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

\r \n line insertions on Darwin to Linux in terminal #227

Open
rjkroege opened this issue Aug 2, 2023 · 3 comments
Open

\r \n line insertions on Darwin to Linux in terminal #227

rjkroege opened this issue Aug 2, 2023 · 3 comments

Comments

@rjkroege
Copy link
Collaborator

rjkroege commented Aug 2, 2023

I have discovered something that seems odd. Maybe it's working as intended but it results in a lot of spurious diff mismatches for me.

When I run cpu without a Pty (i.e. by middle clicking in Acme / Edwood), command results do not contain \r characters. I.e.:

cpu -namespace $_h helios4 echo hello | od -c
0000000    h   e   l   l   o  \n                                        
0000006

But when I run cpu with a Pty (i.e. by typing in a conventional terminal, it does contain \r as part of the line endings. I.e.:

; cpu -namespace $_h helios4 echo hello | od -c
0000000    h   e   l   l   o  \r  \n
0000007
@rjkroege
Copy link
Collaborator Author

rjkroege commented Aug 2, 2023

The difference would appear to be in client.go:/func.*Start

2023/08/02 05:16:48 CPU:start
2023/08/02 05:16:48 CPU:client:c.session.RequestPty("ansi", 87, 157, map[0x35:0x0 0x80:0x3840 0x81:0x3840]
2023/08/02 05:16:48 CPU:client:call session.Start(-port9p=45715 'echo' 'hello')

When executed from a terminal, the cpu client has a pty. So this block is the underlying cause of the presence of the \r.

	if c.hasTTY {
		verbose("c.session.RequestPty(\"ansi\", %v, %v, %#x", c.Row, c.Col, modes)
		if err := c.session.RequestPty("ansi", c.Row, c.Col, modes); err != nil {
			return fmt.Errorf("request for pseudo terminal failed: %v", err)
		}
	}

Hypothesis: modes needs adjustment?

@rjkroege
Copy link
Collaborator Author

rjkroege commented Aug 2, 2023

Aside: why does:

func verbose(f string, a ...interface{}) {
	v("CPU:"+f+"\r\n", a...)
}

append a \r to every log message?

@rjkroege
Copy link
Collaborator Author

rjkroege commented Aug 3, 2023

I hypothesize that this happens because of how gliderlabs/ssh forces the insertion of \r\n when the ssh client requested a pty. I think gliderlabs/ssh#210 (as is included in Tailscale's tailscale/tailscale#4154) would probably fix this issue.

Seems like cpu could use https://github.com/charmbracelet/ssh to fix this bug. I'll try this and update the bug.

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

1 participant