From 4fecd67007595469f6deb4b78d9f12388939810c Mon Sep 17 00:00:00 2001 From: sigoden Date: Tue, 3 Jun 2025 07:50:47 +0800 Subject: fix: better error handling for `aichat -e` on MacOS (#1311) --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index e02c9db..c68b935 100644 --- a/src/main.rs +++ b/src/main.rs @@ -174,9 +174,6 @@ async fn run(config: GlobalConfig, cli: Cli, text: Option) -> Result<()> return Ok(()); } if cli.execute && !is_repl { - if cfg!(target_os = "macos") && !stdin().is_terminal() { - bail!("Unable to read the pipe for shell execution on MacOS") - } let input = create_input(&config, text, &cli.file, abort_signal.clone()).await?; shell_execute(&config, &SHELL, input, abort_signal.clone()).await?; return Ok(()); @@ -265,6 +262,9 @@ async fn shell_execute( return Ok(()); } if *IS_STDOUT_TERMINAL { + if cfg!(target_os = "macos") && !stdin().is_terminal() { + bail!("Unable to read the pipe for shell execution on MacOS") + } let options = ["execute", "revise", "describe", "copy", "quit"]; let command = color_text(eval_str.trim(), nu_ansi_term::Color::Rgb(255, 165, 0)); let first_letter_color = nu_ansi_term::Color::Cyan; -- cgit v1.2.3