Files
bare-operating-system/packages/bare-os-booter/lib/bare-openssh-pty-console.js
T
Raven Scott 2b9a10e371 Normalize embedded newlines to CRLF in SSH child ctx console log/error so
multiline output (e.g. man, bare-slice pager) matches real PTY behavior and
avoids misaligned lines vs the peer terminal.

Mirror pty-req TERM and dimensions into forked session vfs.env (COLUMNS,
LINES) when bareOsForkShellEnv is used; clear target on session end.

Add bare-openssh-pty-console helper module and brittle tests; re-export
formatter from bare-openssh for API parity.
2026-04-09 00:53:45 -04:00

24 lines
716 B
JavaScript

/**
* SSH PTY console newline helpers (no bare-ssh2 import — safe for brittle-node tests).
*/
/**
* Normalize embedded newlines to CRLF for SSH PTY output (multiline `console.log`, e.g. `man`).
* @param {unknown} s
* @returns {string}
*/
export function bareOpensshFormatConsoleTextForPty(s) {
return String(s).replace(/\r?\n/g, '\r\n')
}
/**
* @param {import('stream').Duplex} stream
* @param {unknown[]} args
*/
export function bareOpensshWritePtyConsoleLine(stream, args) {
const body = args.map(String).join(' ')
const normalized = bareOpensshFormatConsoleTextForPty(body)
const out = normalized.endsWith('\r\n') ? normalized : normalized + '\r\n'
if (stream.writable) stream.write(out)
}