summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorcf46844 <none@none>2008-06-05 13:32:08 -0700
committercf46844 <none@none>2008-06-05 13:32:08 -0700
commita035dc19b8f2c7a52a7e5af76c0727dcb4941ea3 (patch)
tree366bd4083b0da28af623e8f200fe0df9283aea1d /usr/src
parent6684e119b80b5cd6e45145fb49cba6b2f3e5580a (diff)
downloadillumos-gate-a035dc19b8f2c7a52a7e5af76c0727dcb4941ea3.tar.gz
6706265 UNIX03: *xargs* output contains trailing newline
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/xargs/xargs.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr/src/cmd/xargs/xargs.c b/usr/src/cmd/xargs/xargs.c
index b4c6c84639..87f7a04e13 100644
--- a/usr/src/cmd/xargs/xargs.c
+++ b/usr/src/cmd/xargs/xargs.c
@@ -99,6 +99,7 @@ static int mac; /* modified argc, after parsing */
static char **mav; /* modified argv, after parsing */
static int n_inserts; /* # of insertions. */
static int inquote = 0; /* processing a quoted string */
+static int save_index = 0;
/*
* the pio structure is used to save any pending input before the
@@ -376,9 +377,16 @@ main(int argc, char **argv)
lastarg = "";
}
- while (((ARGV - arglist) < MAXARGS) &&
- ((*ARGV++ = getarg()) != NULL) && OK)
- ;
+ while (((*ARGV++ = getarg()) != NULL) && OK) {
+ if ((ARGV - arglist) == MAXARGS) {
+ save_index = ARGV - arglist;
+ break;
+ }
+ }
+ if ((save_index == MAXARGS) && !MORE && (N_args == 0)) {
+ /* there were no more args after filling arglist */
+ exit(exitstat);
+ }
/* insert arg if requested */