diff options
author | Ron Yorston <rmy@pobox.com> | 2020-02-19 11:01:39 +0000 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-04-29 15:53:51 +0200 |
commit | 1c462d47a0bc92f9f57af223456df53169acf3fe (patch) | |
tree | 8ded03ad3eaa86b931d42c70492f404107fa9e4e /findutils/xargs.c | |
parent | ed8af51b600fd16d22c6663a241547c3a9d7f2b4 (diff) | |
download | busybox-w32-1c462d47a0bc92f9f57af223456df53169acf3fe.tar.gz busybox-w32-1c462d47a0bc92f9f57af223456df53169acf3fe.tar.bz2 busybox-w32-1c462d47a0bc92f9f57af223456df53169acf3fe.zip |
xargs: restore correct behaviour of -n option
Since commit 1ff7002b1 (xargs: fix handling of quoted arguments, closes
11441) the -n option hasn't worked properly:
$ echo 1 2 3 | xargs -n 1 echo
1
2
3
$
Because state is now remembered between calls to process_stdin() it's
necessary to update the state before any premature return.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'findutils/xargs.c')
-rw-r--r-- | findutils/xargs.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/findutils/xargs.c b/findutils/xargs.c index 4fb306bb8..ff04bfe7c 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c | |||
@@ -315,6 +315,7 @@ static char* FAST_FUNC process_stdin(int n_max_chars, int n_max_arg, char *buf) | |||
315 | } | 315 | } |
316 | } | 316 | } |
317 | if (state == SPACE) { /* word's delimiter or EOF detected */ | 317 | if (state == SPACE) { /* word's delimiter or EOF detected */ |
318 | state = NORM; | ||
318 | if (q) { | 319 | if (q) { |
319 | bb_error_msg_and_die("unmatched %s quote", | 320 | bb_error_msg_and_die("unmatched %s quote", |
320 | q == '\'' ? "single" : "double"); | 321 | q == '\'' ? "single" : "double"); |
@@ -335,7 +336,6 @@ static char* FAST_FUNC process_stdin(int n_max_chars, int n_max_arg, char *buf) | |||
335 | if (n_max_arg == 0) { | 336 | if (n_max_arg == 0) { |
336 | goto ret; | 337 | goto ret; |
337 | } | 338 | } |
338 | state = NORM; | ||
339 | } | 339 | } |
340 | if (p == buf) { | 340 | if (p == buf) { |
341 | goto ret; | 341 | goto ret; |