mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 07:30:52 -07:00
fix: prevent /copy crash on Windows by skipping /dev/tty (#15657)
Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
This commit is contained in:
@@ -66,13 +66,19 @@ const SCREEN_DCS_CHUNK_SIZE = 240;
|
||||
type TtyTarget = { stream: Writable; closeAfter: boolean } | null;
|
||||
|
||||
const pickTty = (): TtyTarget => {
|
||||
// Prefer the controlling TTY to avoid interleaving escape sequences with piped stdout.
|
||||
try {
|
||||
const devTty = fs.createWriteStream('/dev/tty');
|
||||
return { stream: devTty, closeAfter: true };
|
||||
} catch {
|
||||
// fall through
|
||||
// /dev/tty is only available on Unix-like systems (Linux, macOS, BSD, etc.)
|
||||
if (process.platform !== 'win32') {
|
||||
// Prefer the controlling TTY to avoid interleaving escape sequences with piped stdout.
|
||||
try {
|
||||
const devTty = fs.createWriteStream('/dev/tty');
|
||||
// Prevent unhandled 'error' events from crashing the process.
|
||||
devTty.on('error', () => {});
|
||||
return { stream: devTty, closeAfter: true };
|
||||
} catch {
|
||||
// fall through - /dev/tty not accessible
|
||||
}
|
||||
}
|
||||
|
||||
if (process.stderr?.isTTY)
|
||||
return { stream: process.stderr, closeAfter: false };
|
||||
if (process.stdout?.isTTY)
|
||||
|
||||
Reference in New Issue
Block a user