diff --git a/src/xargs/mod.rs b/src/xargs/mod.rs index cf3638df..9679a05a 100644 --- a/src/xargs/mod.rs +++ b/src/xargs/mod.rs @@ -1159,7 +1159,7 @@ fn do_xargs(args: &[&str]) -> Result { options.exit_if_pass_char_limit, options.max_args, options.max_lines, - options.no_run_if_empty, + options.no_run_if_empty || options.replace.is_some(), ), )?; Ok(result) diff --git a/tests/test_xargs.rs b/tests/test_xargs.rs index 3faa0421..3bbe17f2 100644 --- a/tests/test_xargs.rs +++ b/tests/test_xargs.rs @@ -73,6 +73,15 @@ fn xargs_if_empty() { ucmd().args(&["--no-run-if-empty"]).succeeds().no_output(); } +#[test] +fn xargs_replace_empty_input() { + ucmd() + .args(&["-I", "{}", "echo", "hello", "{}"]) + .succeeds() + .no_output(); + ucmd().args(&["-i", "echo", "{}"]).succeeds().no_output(); +} + #[test] fn xargs_max_args() { ucmd()