From c0fd33aaef5f345566a41c7c2558f27adf05558b Mon Sep 17 00:00:00 2001
From: Tavian Barnes <tavianator@tavianator.com>
Date: Mon, 3 Jun 2024 14:34:54 -0400
Subject: parse: Handle multiple flags at once like -LEXO2

The POSIX Utility Syntax Guidelines specify that flag groups like -HL
should be handled like -H -L.  GNU find doesn't support grouping flags
in this way, but BSD find does.

To avoid conflicts with non-flag primaries, for now we require at least
one flag in a group to be a capital letter.  That is, we support things
like -Lds but not -ds.  We also do not support -fPATH (without a space)
as it would conflict with -follow, -fprint, etc.  It is impossible to be
compatible with both GNU and BSD find here:

    user@gnu$ find -follow
    link
    link/file
    ...
    user@bsd$ find -follow
    find: ollow: No such file or directory

Link: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
---
 tests/bfs/LD_stat.out | 17 +++++++++++++++++
 tests/bfs/LD_stat.sh  |  1 +
 tests/bfs/O_3.sh      |  1 +
 tests/bsd/Hf.out      |  1 +
 tests/bsd/Hf.sh       |  1 +
 tests/common/HLP.out  |  1 +
 tests/common/HLP.sh   |  1 +
 tests/posix/HL.out    | 17 +++++++++++++++++
 tests/posix/HL.sh     |  1 +
 tests/posix/LH.out    |  1 +
 tests/posix/LH.sh     |  1 +
 11 files changed, 43 insertions(+)
 create mode 100644 tests/bfs/LD_stat.out
 create mode 100644 tests/bfs/LD_stat.sh
 create mode 100644 tests/bfs/O_3.sh
 create mode 100644 tests/bsd/Hf.out
 create mode 100644 tests/bsd/Hf.sh
 create mode 100644 tests/common/HLP.out
 create mode 100644 tests/common/HLP.sh
 create mode 100644 tests/posix/HL.out
 create mode 100644 tests/posix/HL.sh
 create mode 100644 tests/posix/LH.out
 create mode 100644 tests/posix/LH.sh

(limited to 'tests')

diff --git a/tests/bfs/LD_stat.out b/tests/bfs/LD_stat.out
new file mode 100644
index 0000000..ec9e861
--- /dev/null
+++ b/tests/bfs/LD_stat.out
@@ -0,0 +1,17 @@
+links
+links/broken
+links/deeply
+links/deeply/nested
+links/deeply/nested/broken
+links/deeply/nested/dir
+links/deeply/nested/file
+links/deeply/nested/link
+links/file
+links/hardlink
+links/notdir
+links/skip
+links/skip/broken
+links/skip/dir
+links/skip/file
+links/skip/link
+links/symlink
diff --git a/tests/bfs/LD_stat.sh b/tests/bfs/LD_stat.sh
new file mode 100644
index 0000000..d407de3
--- /dev/null
+++ b/tests/bfs/LD_stat.sh
@@ -0,0 +1 @@
+bfs_diff -LD stat links
diff --git a/tests/bfs/O_3.sh b/tests/bfs/O_3.sh
new file mode 100644
index 0000000..f159852
--- /dev/null
+++ b/tests/bfs/O_3.sh
@@ -0,0 +1 @@
+! invoke_bfs -O 3 basic
diff --git a/tests/bsd/Hf.out b/tests/bsd/Hf.out
new file mode 100644
index 0000000..ff635ff
--- /dev/null
+++ b/tests/bsd/Hf.out
@@ -0,0 +1 @@
+links/deeply/nested/dir
diff --git a/tests/bsd/Hf.sh b/tests/bsd/Hf.sh
new file mode 100644
index 0000000..333280c
--- /dev/null
+++ b/tests/bsd/Hf.sh
@@ -0,0 +1 @@
+bfs_diff -Hf links/deeply/nested/dir
diff --git a/tests/common/HLP.out b/tests/common/HLP.out
new file mode 100644
index 0000000..ff635ff
--- /dev/null
+++ b/tests/common/HLP.out
@@ -0,0 +1 @@
+links/deeply/nested/dir
diff --git a/tests/common/HLP.sh b/tests/common/HLP.sh
new file mode 100644
index 0000000..4b6d631
--- /dev/null
+++ b/tests/common/HLP.sh
@@ -0,0 +1 @@
+bfs_diff -HLP links/deeply/nested/dir
diff --git a/tests/posix/HL.out b/tests/posix/HL.out
new file mode 100644
index 0000000..ec9e861
--- /dev/null
+++ b/tests/posix/HL.out
@@ -0,0 +1,17 @@
+links
+links/broken
+links/deeply
+links/deeply/nested
+links/deeply/nested/broken
+links/deeply/nested/dir
+links/deeply/nested/file
+links/deeply/nested/link
+links/file
+links/hardlink
+links/notdir
+links/skip
+links/skip/broken
+links/skip/dir
+links/skip/file
+links/skip/link
+links/symlink
diff --git a/tests/posix/HL.sh b/tests/posix/HL.sh
new file mode 100644
index 0000000..1858982
--- /dev/null
+++ b/tests/posix/HL.sh
@@ -0,0 +1 @@
+bfs_diff -HL links
diff --git a/tests/posix/LH.out b/tests/posix/LH.out
new file mode 100644
index 0000000..ff635ff
--- /dev/null
+++ b/tests/posix/LH.out
@@ -0,0 +1 @@
+links/deeply/nested/dir
diff --git a/tests/posix/LH.sh b/tests/posix/LH.sh
new file mode 100644
index 0000000..ef1d980
--- /dev/null
+++ b/tests/posix/LH.sh
@@ -0,0 +1 @@
+bfs_diff -LH links/deeply/nested/dir
-- 
cgit v1.2.3