diff --git a/usr.bin/xargs/tests/Makefile b/usr.bin/xargs/tests/Makefile index 2004d797f5df..cd14813aedc9 100644 --- a/usr.bin/xargs/tests/Makefile +++ b/usr.bin/xargs/tests/Makefile @@ -10,13 +10,16 @@ FILES+= regress.0.out FILES+= regress.0I.out FILES+= regress.0J.out FILES+= regress.0L.out +FILES+= regress.0P1.out FILES+= regress.I.out FILES+= regress.J.out FILES+= regress.L.out +FILES+= regress.P1.out FILES+= regress.R.out FILES+= regress.in FILES+= regress.n1.out FILES+= regress.n2.out +FILES+= regress.n2P0.out FILES+= regress.n3.out FILES+= regress.normal.out FILES+= regress.quotes.in diff --git a/usr.bin/xargs/tests/regress.0P1.out b/usr.bin/xargs/tests/regress.0P1.out new file mode 100644 index 000000000000..a95e9a252575 --- /dev/null +++ b/usr.bin/xargs/tests/regress.0P1.out @@ -0,0 +1,4 @@ +quick ' brown fox jumped +over "the lazy dog +quick brown fox jumped over the lazy dog + diff --git a/usr.bin/xargs/tests/regress.P1.out b/usr.bin/xargs/tests/regress.P1.out new file mode 100644 index 000000000000..cc32a92a2199 --- /dev/null +++ b/usr.bin/xargs/tests/regress.P1.out @@ -0,0 +1 @@ +quick brown fox jumped over the lazy dog diff --git a/usr.bin/xargs/tests/regress.n2P0.out b/usr.bin/xargs/tests/regress.n2P0.out new file mode 100644 index 000000000000..4fa3f55161d6 --- /dev/null +++ b/usr.bin/xargs/tests/regress.n2P0.out @@ -0,0 +1,4 @@ +quick brown +fox jumped +over the +lazy dog diff --git a/usr.bin/xargs/tests/regress.sh b/usr.bin/xargs/tests/regress.sh index 316365d95d6e..c75136c8e764 100644 --- a/usr.bin/xargs/tests/regress.sh +++ b/usr.bin/xargs/tests/regress.sh @@ -1,6 +1,6 @@ # $FreeBSD$ -echo 1..13 +echo 1..16 REGRESSION_START($1) @@ -8,14 +8,17 @@ REGRESSION_TEST(`normal', `xargs echo The <${SRCDIR}/regress.in') REGRESSION_TEST(`I', `xargs -I% echo The % % % %% % % <${SRCDIR}/regress.in') REGRESSION_TEST(`J', `xargs -J% echo The % again. <${SRCDIR}/regress.in') REGRESSION_TEST(`L', `xargs -L3 echo <${SRCDIR}/regress.in') +REGRESSION_TEST(`P1', `xargs -P1 echo <${SRCDIR}/regress.in') REGRESSION_TEST(`R', `xargs -I% -R1 echo The % % % %% % % <${SRCDIR}/regress.in') REGRESSION_TEST(`n1', `xargs -n1 echo <${SRCDIR}/regress.in') REGRESSION_TEST(`n2', `xargs -n2 echo <${SRCDIR}/regress.in') +REGRESSION_TEST(`n2P0',`xargs -n2 -P0 echo <${SRCDIR}/regress.in') REGRESSION_TEST(`n3', `xargs -n3 echo <${SRCDIR}/regress.in') REGRESSION_TEST(`0', `xargs -0 -n1 echo <${SRCDIR}/regress.0.in') REGRESSION_TEST(`0I', `xargs -0 -I% echo The % %% % <${SRCDIR}/regress.0.in') REGRESSION_TEST(`0J', `xargs -0 -J% echo The % again. <${SRCDIR}/regress.0.in') REGRESSION_TEST(`0L', `xargs -0 -L2 echo <${SRCDIR}/regress.0.in') +REGRESSION_TEST(`0P1', `xargs -0 -P1 echo <${SRCDIR}/regress.0.in') REGRESSION_TEST(`quotes', `xargs -n1 echo <${SRCDIR}/regress.quotes.in') REGRESSION_END() diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index c69a23a8b441..c56ab6045ad0 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -166,15 +166,11 @@ main(int argc, char *argv[]) oflag = 1; break; case 'P': - maxprocs = strtonum(optarg, 1, INT_MAX, &errstr); + maxprocs = strtonum(optarg, 0, INT_MAX, &errstr); if (errstr) errx(1, "-P %s: %s", optarg, errstr); if (getrlimit(RLIMIT_NPROC, &rl) != 0) errx(1, "getrlimit failed"); - if (*endptr != '\0') - errx(1, "invalid number for -P option"); - if (maxprocs < 0) - errx(1, "value for -P option should be >= 0"); if (maxprocs == 0 || maxprocs > rl.rlim_cur) maxprocs = rl.rlim_cur; break;