From 8104c4789ffdb2123754f754f12a44ab68704d9c Mon Sep 17 00:00:00 2001 From: Paulo Aboim Pinto Date: Wed, 27 May 2026 17:52:52 +0200 Subject: [PATCH] fix(tui): handle bash on windows separately --- crates/tui/src/sandbox/mod.rs | 26 +++++++++++++------------- crates/tui/src/tools/shell/tests.rs | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/tui/src/sandbox/mod.rs b/crates/tui/src/sandbox/mod.rs index 9c4d2b52..22864c60 100644 --- a/crates/tui/src/sandbox/mod.rs +++ b/crates/tui/src/sandbox/mod.rs @@ -99,8 +99,10 @@ impl CommandSpec { | crate::shell_dispatcher::ShellKind::WindowsPowerShell ) { format!("[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; {command}") - } else { + } else if matches!(kind, crate::shell_dispatcher::ShellKind::Cmd) { format!("chcp 65001 >NUL & {command}") + } else { + command.to_string() }; dispatcher.build_command_parts(&cmd) }; @@ -667,17 +669,15 @@ mod tests { ] ); } else { - assert_eq!( - spec.args, - if cfg!(windows) { - vec!["/C".to_string(), format!("chcp 65001 >NUL & {cmd}")] - } else { - vec![ - dispatcher.kind().command_flag().to_string(), - cmd.to_string(), - ] - } - ); + let expected = if matches!(dispatcher.kind(), crate::shell_dispatcher::ShellKind::Cmd) { + vec!["/C".to_string(), format!("chcp 65001 >NUL & {cmd}")] + } else { + vec![ + dispatcher.kind().command_flag().to_string(), + cmd.to_string(), + ] + }; + assert_eq!(spec.args, expected); // The quoted message is intact in a single argv slot — shell `-c` // performs POSIX tokenization, yielding the correct argv: // ["git","commit","-m","feat: complete sub-pages"]. @@ -754,7 +754,7 @@ mod tests { .to_string(), ] ); - } else if cfg!(windows) { + } else if matches!(dispatcher.kind(), crate::shell_dispatcher::ShellKind::Cmd) { assert_eq!( env.command, vec![ diff --git a/crates/tui/src/tools/shell/tests.rs b/crates/tui/src/tools/shell/tests.rs index b73cb602..7bcd643c 100644 --- a/crates/tui/src/tools/shell/tests.rs +++ b/crates/tui/src/tools/shell/tests.rs @@ -936,7 +936,7 @@ fn issue_1691_quoted_commit_message_round_trips() { format!("[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; {cmd}") ] ); - } else if cfg!(windows) { + } else if matches!(dispatcher.kind(), crate::shell_dispatcher::ShellKind::Cmd) { assert_eq!( spec.args, ["/C".to_string(), format!("chcp 65001 >NUL & {cmd}")]