fix(builtins): handled empty xargs replace input

- Prevented replace mode from executing without a stdin argument.

- Covered the GNU-compatible empty-input no-op contract.

Fixes #8595
This commit is contained in:
roboomp
2026-08-15 00:24:29 +00:00
parent ffd53ff92a
commit 7f5590258e
2 changed files with 11 additions and 1 deletions
+7 -1
View File
@@ -741,7 +741,7 @@ fn process_input(
return Ok(result);
}
if !options.no_run_if_empty || have_pending_command {
if have_pending_command || (!options.no_run_if_empty && builder_options.replace.is_none()) {
result.combine(current_builder.execute(host)?);
}
@@ -1468,6 +1468,12 @@ mod tests {
assert_eq!(out, "\n");
}
#[test]
fn replace_mode_skips_empty_input_without_r() {
let result = run_simple(&["-I", "{}", "echo", "{}"], "");
assert_eq!(result, (0, String::new(), String::new()));
}
#[test]
fn verbose_echoes_command_line_to_stderr() {
let (code, out, err) = run_simple(&["-t", "echo", "a"], "b\n");
+4
View File
@@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed the native `xargs` builtin panicking in `-I`/`-i` replace mode when stdin is empty; it now exits successfully without running the command, matching GNU behavior ([#8595](https://github.com/can1357/oh-my-pi/issues/8595)).
## [17.3.4] - 2026-08-14
### Added