From nobody Thu Jul 13 21:37:24 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4R27HS2wNLz4mYgL; Thu, 13 Jul 2023 21:37:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4R27HS2GKrz3sq4; Thu, 13 Jul 2023 21:37:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689284244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RG3Own+ZHqDuiUlE4+pfE2veVR8MgNu4RMk6vziD87o=; b=qY7nP7mkGQG8S0vygcq8JI4hkwPVwuGqcEcH7oiANloJE1dNaFH14OJimm7nX3SmXsGUmb Vwg2Uoww9eP78DbvLY5QXA9P7W3jlHpRMUUoRlV0tX2krYcz3QcnqcFhIcjCkGm7usMWdp 18JBtmAYWVZA/vtqgk8A7RfW/LWVw6TKtYaH8xIsJSfqrWlZzXGFcXfKVhv+2mHNmBxQR7 PsaALJjueIGEL6aijZsYo2gt7BCW08blnyg0eYReMcOZYqIFfUFXSgQnaZq8ZNQy2yD3EK wPCzP2HsO8ZmskPiQjX/QmIB/XzaJ9OAe/Mtl6cIwwRZScqCRUUKeyHM2a7w6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689284244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RG3Own+ZHqDuiUlE4+pfE2veVR8MgNu4RMk6vziD87o=; b=J2S2v8BW1vbQdclVO9DCPLdt/5df9QMN3npKqMTN2GowCtWZEFuUmzysfC2uCFZ7BvEKsq Otq/1VyieckN4s6yVgLjFMMFJi4BSa08pG0o+SHRrosXDC0zo99TlTL+SBPx7zgWnW4Sm/ DRYkP/EZwDpS1P0JDm2zFvEZVNc0oQD9fFpSuSZTVPIqwQKck5YNfwuJ7n4vTETY2zJpuo tgL80+quZGvzUxCdK+T46iR+aaqfzXq10B7nAkMRLibZDi1p6d3KqJhvWplPW/n1wgCnVq /KYN1AovTI47mqnl3mgxFDtq5EDRp47CZQE+uakYzFFJCV0ooP+QUcxjQdOx1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689284244; a=rsa-sha256; cv=none; b=i45qDE/xRveqMi/0Sl6F32Q2gfNu9c02DHC7x5XmBxQRvR/Ne0nl0NkMHZD3ws3WLyu+oo 94YL0d7xQIDsBomad94zeGGpYsIhMCHPKebuQQdlGNvIl4xOQ1FeT2PP8zsHvOTGQqt1rK 20cGfJxD0krnAxXjtULGistR0OjHuuNsrTcwkFXCNazYlwUAMqG+d3SBgWrSqbWBm9+16L pRDRXLV9P+MI9HQKRZOb+flgyPYrjPtpzOHqHn+uRLnIRk/EhMmJYfntjv+Vnc6s7eD96b mJOm1uY6W1y7jOmiMHnz17nHdZf9MgJjQoO8QKRpcM1tcHXaPiydTRHzgq/3fw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4R27HS1BZ5z16X9; Thu, 13 Jul 2023 21:37:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36DLbO90022767; Thu, 13 Jul 2023 21:37:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36DLbOGk022766; Thu, 13 Jul 2023 21:37:24 GMT (envelope-from git) Date: Thu, 13 Jul 2023 21:37:24 GMT Message-Id: <202307132137.36DLbOGk022766@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= Subject: git: 202adb223610 - main - xargs: fix -R so that it accepts negative numbers again List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 202adb2236104141dc02d512084a3cc4bbe734c7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=202adb2236104141dc02d512084a3cc4bbe734c7 commit 202adb2236104141dc02d512084a3cc4bbe734c7 Author: Daniel Tameling AuthorDate: 2023-07-13 20:06:14 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2023-07-13 21:35:23 +0000 xargs: fix -R so that it accepts negative numbers again fbc445addf9 converted the parsing of arguments to strtonum but made the accepted range for -R too restrictive. As documented in the man page, it should accept negative numbers. Added a test for this, which was provided by Jose Luis Duran. Fixes: fbc445addf9 MFC after: 1 week Reviewed by: des, kevans Differential Revision: https://reviews.freebsd.org/D41021 --- usr.bin/xargs/tests/Makefile | 1 + usr.bin/xargs/tests/regress.R-1.out | 4 ++++ usr.bin/xargs/tests/regress.sh | 3 ++- usr.bin/xargs/xargs.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/usr.bin/xargs/tests/Makefile b/usr.bin/xargs/tests/Makefile index 228c1d545781..6bb861a6d27a 100644 --- a/usr.bin/xargs/tests/Makefile +++ b/usr.bin/xargs/tests/Makefile @@ -15,6 +15,7 @@ ${PACKAGE}FILES+= regress.J.out ${PACKAGE}FILES+= regress.L.out ${PACKAGE}FILES+= regress.P1.out ${PACKAGE}FILES+= regress.R.out +${PACKAGE}FILES+= regress.R-1.out ${PACKAGE}FILES+= regress.in ${PACKAGE}FILES+= regress.n1.out ${PACKAGE}FILES+= regress.n2.out diff --git a/usr.bin/xargs/tests/regress.R-1.out b/usr.bin/xargs/tests/regress.R-1.out new file mode 100644 index 000000000000..7bdf58090c60 --- /dev/null +++ b/usr.bin/xargs/tests/regress.R-1.out @@ -0,0 +1,4 @@ +The quick brown quick brown quick brown quick brownquick brown quick brown quick brown +The fox jumped fox jumped fox jumped fox jumpedfox jumped fox jumped fox jumped +The over the lazy over the lazy over the lazy over the lazyover the lazy over the lazy over the lazy +The dog dog dog dogdog dog dog diff --git a/usr.bin/xargs/tests/regress.sh b/usr.bin/xargs/tests/regress.sh index e79bfd4352fa..ed81d66bf2a6 100644 --- a/usr.bin/xargs/tests/regress.sh +++ b/usr.bin/xargs/tests/regress.sh @@ -1,6 +1,6 @@ # $FreeBSD$ -echo 1..20 +echo 1..21 REGRESSION_START($1) @@ -10,6 +10,7 @@ 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(`R-1', `xargs -I% -R-1 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 | sort') diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index e832cbb35a31..94a32d04fd67 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -200,7 +200,7 @@ main(int argc, char *argv[]) pflag = 1; break; case 'R': - Rflag = (int)strtonum(optarg, 0, INT_MAX, &errstr); + Rflag = (int)strtonum(optarg, INT_MIN, INT_MAX, &errstr); if (errstr) errx(1, "-%c %s: %s", ch, optarg, errstr); break;