Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jan 2024 18:50:00 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 2a121b97e967 - main - find: Allow '/' to be used with -perm for GNU compatibility
Message-ID:  <202401151850.40FIo0GI048838@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=2a121b97e9673ff37062c9fa026eee969940d2e2

commit 2a121b97e9673ff37062c9fa026eee969940d2e2
Author:     Ricardo Branco <rbranco@suse.de>
AuthorDate: 2024-01-15 18:35:27 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-01-15 18:47:24 +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
---
 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 de16b012ce4d..856961d02395 100644
--- a/usr.bin/find/find.1
+++ b/usr.bin/find/find.1
@@ -28,7 +28,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd December 22, 2023
+.Dd January 15, 2024
 .Dt FIND 1
 .Os
 .Sh NAME
@@ -757,7 +757,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
@@ -786,11 +786,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
@@ -1116,6 +1119,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 43aa2301439c..f96a086cbda3 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -1338,7 +1338,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;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401151850.40FIo0GI048838>