Merge pull request #343 from cakebaker/xargs_max_lines

xargs: add --max-lines
This commit is contained in:
Sylvestre Ledru
2024-03-28 22:29:11 +01:00
committed by GitHub
2 changed files with 11 additions and 8 deletions
+1
View File
@@ -774,6 +774,7 @@ fn do_xargs(args: &[&str]) -> Result<CommandResult, XargsError> {
.arg(
Arg::new(options::MAX_LINES)
.short('L')
.long(options::MAX_LINES)
.help(
"Set the max number of lines from stdin to be passed to each \
command invocation (mutually exclusive with -n)",
+10 -8
View File
@@ -114,14 +114,16 @@ fn xargs_max_args() {
#[test]
fn xargs_max_lines() {
Command::cargo_bin("xargs")
.expect("found binary")
.args(["-L2"])
.write_stdin("ab cd\nef\ngh i\n\njkl\n")
.assert()
.success()
.stderr(predicate::str::is_empty())
.stdout(predicate::str::diff("ab cd ef\ngh i jkl\n"));
for arg in ["-L2", "--max-lines=2"] {
Command::cargo_bin("xargs")
.expect("found binary")
.arg(arg)
.write_stdin("ab cd\nef\ngh i\n\njkl\n")
.assert()
.success()
.stderr(predicate::str::is_empty())
.stdout(predicate::str::diff("ab cd ef\ngh i jkl\n"));
}
}
#[test]