From nobody Mon Apr 08 20:25:41 2024 X-Original-To: dev-commits-src-all@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 4VD0w55DcHz5HhVX; Mon, 8 Apr 2024 20:25:41 +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 4VD0w53pr1z3xcN; Mon, 8 Apr 2024 20:25:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712607941; 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=iK+b7ItSQi+d+diM/BXhaZvtalgiDhIjH+Q6caIkAN8=; b=B6dEhFw78MdB9MVAj4sHhFltFwL7BaeeGb36niBO40jyfmefD0ewDCOg6+BdZa81h/fbEW aSUtMA9z7LgUyHnDrEpmxYZndbw0i5ECO7ezff7wj23LApwyc7qyJi+Y+iupphkQ7hTd6V KJOrdvb2+oZkRzvuJ3e2JiXyX6uGMQDlZLmADfvzptR36cUizg81rAptOiwf6B5F1v3LER xNy6V61s9t266UJWprkNiLcCYu+wIl/PYx9RfdyyGabeTYJuk36Vo9pUWydZXciVuvd8z+ tMTWCYZaIzI6wXGrYfvRpJDyrolNQNIZF4FDg7wbg7i8zsN+FIHz85zd17Forg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712607941; a=rsa-sha256; cv=none; b=Lnaxj2BWMGTgigj9fzK9o49LDCx47M6gLKhCcFBhjk2zNFhI4Z8b+8i5MPxUl6uup1yIvL nS12+GM8hu8kjH+n7MTbz8VfaRDzeq7C4WCq+nON5/n0uzdX3KNYujLiK94fDHawWQj7B7 vWr0xbtM5fcKNCPZ1qI0idhPY5Ykgt0wej9x8KxqdzX+38QCwqB9GZNx3vYzv6eoJNhsq8 YtKZBPM6vOhZZ43g0B6pOqeFClB/KB/YmYGfcd3013PWum15vOoe1RSCLhHTf3EqxMdlnt mxd2iUEYwP94nCnHMnhZgcgwfcFpt4e9J11CrQ5qenbMZxMmMMiFHkiIM/q6dw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712607941; 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=iK+b7ItSQi+d+diM/BXhaZvtalgiDhIjH+Q6caIkAN8=; b=GUtJ3fqZL9YnIrYWQHMXMTcLdea0Om06gLAQWOfY6nrxdEnKItZQpPGyvOgf5/iIeIW2mx lo9JPxxwN2jyunBLrH4dkh3e+J0GuJ69hqo5MzoCsxD+MOCKgPaufkWAMxgvPlaOaPFCWb w6/O9Bjg1r2QFgj0mab9bF63LMBo7mshJlSp/5SzyjsjIlEdJW4CZtEp9zh/AP2Xt1jNyK KRPlkbqHeLLPOGIIE2G/5lYojzyOjVbhXaV6cnamWl4Rlg6bDfk8on3FcpYqGb8oSaWLYb 5iUeL+zwWAfGqQ7iXFUamfN8IVmwnod+QisQb1zdYcQadoI3Js1jQNYtI4p1sQ== 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 4VD0w53QDszQc0; Mon, 8 Apr 2024 20:25:41 +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 438KPfWl039484; Mon, 8 Apr 2024 20:25:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 438KPfhL039481; Mon, 8 Apr 2024 20:25:41 GMT (envelope-from git) Date: Mon, 8 Apr 2024 20:25:41 GMT Message-Id: <202404082025.438KPfhL039481@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 77afa8bc52fc - stable/13 - find: Allow '/' to be used with -perm for GNU compatibility List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 77afa8bc52fcfbf3960751fe8589171dfcc9f9bf Auto-Submitted: auto-generated The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=77afa8bc52fcfbf3960751fe8589171dfcc9f9bf commit 77afa8bc52fcfbf3960751fe8589171dfcc9f9bf Author: Ricardo Branco AuthorDate: 2024-01-15 18:35:27 +0000 Commit: John Baldwin CommitDate: 2024-04-08 17:33:29 +0000 find: Allow '/' to be used with -perm for GNU compatibility In 2005, Gnu find deprecated '+' as the leading character for the -perm argument, instead preferring '/' with the same meaning. Implement that behavior here, and document it in the man page. Reviewed by: imp, emaste Pull Request: https://github.com/freebsd/freebsd-src/pull/1060 (cherry picked from commit 2a121b97e9673ff37062c9fa026eee969940d2e2) --- usr.bin/find/find.1 | 19 ++++++++++++++++--- usr.bin/find/function.c | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index afa4c7ab8215..a73196180e7c 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -30,7 +30,7 @@ .\" .\" @(#)find.1 8.7 (Berkeley) 5/9/95 .\" -.Dd December 22, 2023 +.Dd January 15, 2024 .Dt FIND 1 .Os .Sh NAME @@ -759,7 +759,7 @@ Slashes .Pq Dq Li / are treated as normal characters and do not have to be matched explicitly. -.It Ic -perm Oo Cm - Ns | Ns Cm + Oc Ns Ar mode +.It Ic -perm Oo Cm - Ns | Ns Cm + Ns | Ns Cm / Oc Ns Ar mode The .Ar mode may be either symbolic (see @@ -788,11 +788,14 @@ are set in the file's mode bits. If the .Ar mode is preceded by a plus -.Pq Dq Li + , +.Pq Dq Li + this primary evaluates to true if any of the bits in the .Ar mode are set in the file's mode bits. +A slash +.Pq Dq Li / +is also accepted with the same meaning as plus for compatibility with GNU find. Otherwise, this primary evaluates to true if the bits in the .Ar mode @@ -1118,6 +1121,16 @@ option was inspired by the equivalent and .Xr sed 1 options. +.Pp +The +.Ic -perm +primary accepts a leading slash +.Pq Dq Li / +as an alias for a leading plus +.Pq Dq Li + +for its argument as an extension of +.St -p1003.1-2001 +to be compatible with GNU find. .Sh HISTORY A simple .Nm diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index d887c8479099..9c1fd4df8731 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1343,7 +1343,7 @@ c_perm(OPTION *option, char ***argvp) if (*perm == '-') { new->flags |= F_ATLEAST; ++perm; - } else if (*perm == '+') { + } else if (*perm == '+' || *perm == '/') { new->flags |= F_ANY; ++perm; }