← Commit list

1c462d47a

Ron Yorston
Ron Yorston
2020-04-29
SUCCESS Duration: 154s

Subject

xargs: restore correct behaviour of -n option

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

findutils/xargs.c+1 -1
@@ -315,6 +315,7 @@ static char* FAST_FUNC process_stdin(int n_max_chars, int n_max_arg, char *buf)
}
}
if (state == SPACE) { /* word's delimiter or EOF detected */
+ state = NORM;
if (q) {
bb_error_msg_and_die("unmatched %s quote",
q == '\'' ? "single" : "double");
@@ -335,7 +336,6 @@ static char* FAST_FUNC process_stdin(int n_max_chars, int n_max_arg, char *buf)
if (n_max_arg == 0) {
goto ret;
}
- state = NORM;
}
if (p == buf) {
goto ret;
testsuite/xargs.tests+11 -0
@@ -48,6 +48,17 @@ testing "xargs argument line too long" \
"seq 10000 99999 | sed -e 's/^/\"/' -e 's/$/\"/' | xargs echo | grep -o 99999; echo \$?" \
"99999\n0\n" \
"" ""
+
+testing "xargs -n1" \
+ "xargs -n1 echo" \
+ "1\n2\n3\n4\n5\n" \
+ "" "1 2 3 4 5\n"
+
+testing "xargs -n2" \
+ "xargs -n2 echo" \
+ "1 2\n3 4\n5\n" \
+ "" "1 2 3 4 5\n"
+
SKIP=
exit $FAILCOUNT