This is a simple fix for a problem richlowe (and others — Joyent OS-3009 for
example) have found. Easy fix. Diffs below. (The first stanza isn’t strictly
necessary, but I find it makes the boolean logic easier to validate if the
parens are properly placed. :-)
Thanks.
With this fix I get correct behavior. (I’ve also tested -L2, etc. :-)
> printf 'foo bar baz other\n' | ./xargs -I THING echo '** THING ** '
** foo bar baz other **
I should probably add a test suite for xargs along the lines of my printf test
suite, and I’ll probably do that if I commit those changes before this. (In
which case I’ll resubmit for review *with* the test suite.)
- Garrett
diff --git a/usr/src/cmd/xargs/xargs.c b/usr/src/cmd/xargs/xargs.c
index e50c7d6..c095355 100644
--- a/usr/src/cmd/xargs/xargs.c
+++ b/usr/src/cmd/xargs/xargs.c
@@ -19,6 +19,7 @@
* CDDL HEADER END
*/
/*
+ * Copyright 2014 Garrett D'Amore <[email protected]>
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
*
* Portions of this file developed by DEY Storage Systems, Inc. are licensed
@@ -421,8 +422,8 @@ main(int argc, char **argv)
N_args++;
- if ((PER_LINE && N_lines >= PER_LINE) ||
- (N_ARGS && (N_args) >= N_ARGS)) {
+ if ((PER_LINE && (N_lines >= PER_LINE)) ||
+ (N_ARGS && (N_args >= N_ARGS))) {
break;
}
@@ -612,7 +613,8 @@ getarg(char *arg)
default:
/* most times we will just want to store it */
- if (inquote || escape || ZERO || !iswctype(c, blank)) {
+ if (inquote || escape || ZERO || PER_LINE ||
+ !iswctype(c, blank)) {
escape = 0;
store_str(&arg, mbc, len);
continue;
--
Garrett D'Amore
Sent with Airmail_______________________________________________
developer mailing list
[email protected]
http://lists.open-zfs.org/mailman/listinfo/developer