pico

created pr with 118.1 on 2026-02-26T03:15:38Z · by c8ef7d19
changed status to accepted on 2026-02-26T19:32:17Z · by c8ef7d19
cmds
checkout latest patchset:
ssh pr.pico.sh print 118 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 118.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 118
set PR to open (enables RSS notifications):
ssh pr.pico.sh pr open 118
set PR to draft (stops RSS notifications):
ssh pr.pico.sh pr draft 118

Patchset 118.1 on 2026-02-26T03:15:38Z · commit b10aef1

+27 -0 pkg/pssh/server.go #
......@@ -1,6 +1,7 @@
11 package pssh
22
33 import (
4+ "bytes"
45 "context"
56 "crypto/ed25519"
67 "crypto/rand"
......@@ -185,6 +186,32 @@ func (s *SSHServerConnSession) Pty() (*Pty, <-chan Window, bool) {
185186 return s.pty, s.winch, true
186187 }
187188
189+// Write overrides the embedded Channel's Write to normalize line endings when PTY is allocated.
190+func (s *SSHServerConnSession) Write(p []byte) (n int, err error) {
191+ s.mu.Lock()
192+ hasPty := s.pty != nil
193+ s.mu.Unlock()
194+
195+ if !hasPty {
196+ // No PTY, write as-is
197+ return s.Channel.Write(p)
198+ }
199+
200+ // When PTY is active, normalize line endings like a real terminal would.
201+ // Replace \n with \r\n, but avoid double \r\n.
202+ normalized := bytes.ReplaceAll(p, []byte{'\n'}, []byte{'\r', '\n'})
203+ normalized = bytes.ReplaceAll(normalized, []byte{'\r', '\r', '\n'}, []byte{'\r', '\n'})
204+
205+ // Write the normalized data
206+ written, err := s.Channel.Write(normalized)
207+
208+ // Return the count based on original data length, not normalized
209+ if written > len(p) {
210+ written = len(p)
211+ }
212+ return written, err
213+}
214+
188215 var _ context.Context = &SSHServerConnSession{}
189216
190217 func (sc *SSHServerConn) Handle(chans <-chan ssh.NewChannel, reqs <-chan *ssh.Request) error {
Back to top