git: 77afa8bc52fc - stable/13 - find: Allow '/' to be used with -perm for GNU compatibility
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Apr 2024 20:25:41 UTC
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=77afa8bc52fcfbf3960751fe8589171dfcc9f9bf commit 77afa8bc52fcfbf3960751fe8589171dfcc9f9bf Author: Ricardo Branco <rbranco@suse.de> AuthorDate: 2024-01-15 18:35:27 +0000 Commit: John Baldwin <jhb@FreeBSD.org> 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; }