diff options
| author | sigoden <sigoden@gmail.com> | 2025-07-05 07:41:11 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-05 07:41:11 +0800 |
| commit | dfa2363b0156291bfe4a96069026853d8db1ce21 (patch) | |
| tree | 080b65fd6036837b69384b654bd15a551ea324e0 /src | |
| parent | d0b499ed92a63dc9ca6264724b4749c4384c91e3 (diff) | |
| download | aichat-dfa2363b0156291bfe4a96069026853d8db1ce21.tar.gz | |
fix: `.file` external commands capture stdout/stderr (#1343)
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/input.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/config/input.rs b/src/config/input.rs index 5c4e0e6..545e99d 100644 --- a/src/config/input.rs +++ b/src/config/input.rs @@ -94,7 +94,7 @@ impl Input { } let documents_len = documents.len(); for (kind, path, contents) in documents { - if documents_len == 1 { + if documents_len == 1 && raw_text.is_empty() { texts.push(format!("\n{contents}")); } else { texts.push(format!( @@ -457,13 +457,12 @@ async fn load_documents( let mut data_urls = HashMap::new(); for cmd in external_cmds { - let (success, stdout, stderr) = - run_command_with_output(&SHELL.cmd, &[&SHELL.arg, &cmd], None)?; - if !success { - let err = if !stderr.is_empty() { stderr } else { stdout }; - bail!("Failed to run `{cmd}`\n{err}"); - } - files.push(("CMD", cmd, stdout)); + let output = duct::cmd(&SHELL.cmd, &[&SHELL.arg, &cmd]) + .stderr_to_stdout() + .unchecked() + .read() + .unwrap_or_else(|err| err.to_string()); + files.push(("CMD", cmd, output)); } let local_files = expand_glob_paths(&local_paths, true).await?; |
