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:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user