summaryrefslogtreecommitdiffstats
path: root/usr.bin/xargs/xargs.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/xargs/xargs.c')
-rw-r--r--usr.bin/xargs/xargs.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c
index 5a97ed3..b4a8b83 100644
--- a/usr.bin/xargs/xargs.c
+++ b/usr.bin/xargs/xargs.c
@@ -80,7 +80,7 @@ static char **av, **bxp, **ep, **endxp, **xp;
static char *argp, *bbp, *ebp, *inpline, *p, *replstr;
static const char *eofstr;
static int count, insingle, indouble, oflag, pflag, tflag, Rflag, rval, zflag;
-static int cnt, Iflag, jfound, Lflag, wasquoted, xflag;
+static int cnt, Iflag, jfound, Lflag, Sflag, wasquoted, xflag;
static int curprocs, maxprocs;
static volatile int childerr;
@@ -124,7 +124,7 @@ main(int argc, char *argv[])
nline -= strlen(*ep++) + 1 + sizeof(*ep);
}
maxprocs = 1;
- while ((ch = getopt(argc, argv, "0E:I:J:L:n:oP:pR:s:rtx")) != -1)
+ while ((ch = getopt(argc, argv, "0E:I:J:L:n:oP:pR:S:s:rtx")) != -1)
switch(ch) {
case 'E':
eofstr = optarg;
@@ -166,6 +166,11 @@ main(int argc, char *argv[])
case 'r':
/* GNU compatibility */
break;
+ case 'S':
+ Sflag = strtoul(optarg, &endptr, 10);
+ if (*endptr != '\0')
+ errx(1, "replsize must be a number");
+ break;
case 's':
nline = atoi(optarg);
break;
@@ -187,8 +192,12 @@ main(int argc, char *argv[])
if (!Iflag && Rflag)
usage();
+ if (!Iflag && Sflag)
+ usage();
if (Iflag && !Rflag)
Rflag = 5;
+ if (Iflag && !Sflag)
+ Sflag = 255;
if (xflag && !nflag)
usage();
if (Iflag || Lflag)
@@ -454,7 +463,7 @@ prerun(int argc, char *argv[])
while (--argc) {
*tmp = *avj++;
if (repls && strstr(*tmp, replstr) != NULL) {
- strnsubst(tmp++, replstr, inpline, (size_t)255);
+ strnsubst(tmp++, replstr, inpline, (size_t)Sflag);
if (repls > 0)
repls--;
} else {
@@ -609,8 +618,8 @@ static void
usage(void)
{
fprintf(stderr,
-"usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]\n"
-" [-L number] [-n number [-x]] [-P maxprocs] [-s size]\n"
-" [utility [argument ...]]\n");
+"usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements] [-S replsize]]\n"
+" [-J replstr] [-L number] [-n number [-x]] [-P maxprocs]\n"
+" [-s size] [utility [argument ...]]\n");
exit(1);
}
OpenPOWER on IntegriCloud