From 445937903801497c602566070e57978f2f9878f8 Mon Sep 17 00:00:00 2001 From: ItsDaRa <73597694+ItsDaRa@users.noreply.github.com> Date: Tue, 3 Mar 2026 02:28:11 +0100 Subject: [PATCH] fix: Avoid creating an empty c:\dev\null file on windows during terminal width detection. (#132) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Windows, the Unix-specific commands (ps, stty, tput) and shell redirects (2>/dev/null) don't work and cause issues: - tput doesn't exist on Windows - 2>/dev/null creates a literal file named "null" instead of redirecting stderr This fix adds a platform check at the start of getTerminalWidth() and canDetectTerminalWidth(). We cannot rely on process.stdout.columns when run as a subprocess of claude code to tell us the actual terminal width. By simply returning that terminal width detection is unavailable on windows, we avoid the empty file being created, and disable explicit truncation behavior since we can't detect the width. Fixes #117 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude * fix: preserve legacy terminal width behavior on Windows Return null/false for win32 in terminal width helpers to keep width detection disabled on Windows and avoid Unix-style fallback paths that can create C:\dev\null. --------- Co-authored-by: ItsDaRa Co-authored-by: Claude Co-authored-by: Matthew Breedlove --- src/utils/terminal.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/utils/terminal.ts b/src/utils/terminal.ts index 394f5e3..ddc5919 100644 --- a/src/utils/terminal.ts +++ b/src/utils/terminal.ts @@ -34,6 +34,12 @@ export function getPackageVersion(): string { // Get terminal width export function getTerminalWidth(): number | null { + // Preserve historical behavior on Windows: width detection is unavailable. + // This avoids Unix fallback command behavior (e.g. 2>/dev/null) on Windows. + if (process.platform === 'win32') { + return null; + } + try { // First try to get the tty of the parent process const tty = execSync('ps -o tty= -p $(ps -o ppid= -p $$)', { @@ -83,6 +89,11 @@ export function getTerminalWidth(): number | null { // Check if terminal width detection is available export function canDetectTerminalWidth(): boolean { + // Preserve historical behavior on Windows: width detection is unavailable. + if (process.platform === 'win32') { + return false; + } + try { // First try to get the tty of the parent process const tty = execSync('ps -o tty= -p $(ps -o ppid= -p $$)', { @@ -123,4 +134,4 @@ export function canDetectTerminalWidth(): boolean { } catch { return false; } -} \ No newline at end of file +}