/** * 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) }