aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuli Mallett <jmallett@FreeBSD.org>2003-02-26 22:44:32 +0000
committerJuli Mallett <jmallett@FreeBSD.org>2003-02-26 22:44:32 +0000
commit3c6751676670a847160f0a5bdc21f64ebd199c99 (patch)
tree4b1d452404f0fffbfd12afd91b7dd078d75bdc70
parent08f16c7ae48d209be8bd14515fed791411d2223c (diff)
downloadsrc-3c6751676670a847160f0a5bdc21f64ebd199c99.tar.gz
src-3c6751676670a847160f0a5bdc21f64ebd199c99.zip
Notes
-rw-r--r--usr.bin/xargs/xargs.13
-rw-r--r--usr.bin/xargs/xargs.c9
2 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/xargs/xargs.1 b/usr.bin/xargs/xargs.1
index bba7aa24ecbe..7c2f70bd3959 100644
--- a/usr.bin/xargs/xargs.1
+++ b/usr.bin/xargs/xargs.1
@@ -211,6 +211,9 @@ No commands are executed if the process is not attached to a terminal.
Specify the maximum number of arguments that
.Fl I
will do replacement in.
+If
+.Ar replacements
+is negative, the number of arguments in which to replace is unbounded.
.It Fl s Ar size
Set the maximum number of bytes for the command line length provided to
.Ar utility .
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c
index 7dc859cee8b4..ec15af7555bc 100644
--- a/usr.bin/xargs/xargs.c
+++ b/usr.bin/xargs/xargs.c
@@ -96,6 +96,7 @@ main(int argc, char *argv[])
long arg_max;
int ch, Jflag, nargs, nflag, nline;
size_t linelen;
+ char *endptr;
inpline = replstr = NULL;
ep = environ;
@@ -158,8 +159,9 @@ main(int argc, char *argv[])
pflag = 1;
break;
case 'R':
- if ((Rflag = atoi(optarg)) <= 0)
- errx(1, "illegal number of replacements");
+ Rflag = strtol(optarg, &endptr, 10);
+ if (*endptr != '\0')
+ errx(1, "replacements must be a number");
break;
case 's':
nline = atoi(optarg);
@@ -444,7 +446,8 @@ prerun(int argc, char *argv[])
*tmp = *avj++;
if (repls && strstr(*tmp, replstr) != NULL) {
strnsubst(tmp++, replstr, inpline, (size_t)255);
- repls--;
+ if (repls > 0)
+ repls--;
} else {
if ((*tmp = strdup(*tmp)) == NULL)
errx(1, "strdup failed");