]> Lady’s Gitweb - Shushe/commitdiff
Make find more cross‐compatible
authorLady <redacted>
Mon, 22 Jan 2024 00:49:17 +0000 (19:49 -0500)
committerLady <redacted>
Mon, 22 Jan 2024 00:49:17 +0000 (19:49 -0500)
The `-flags -nohidden` check doesn’t appear to work in G·N·U Find.
Apparently `-a` and `-o` are the Posix‐correct versions of `-and` and
`-or`, even though both G·N·U and B·S·D find seem to prefer the latter.

The `-type f` check is moved to the end, as it is computationally more
expensive than `-name` and so would benefit from an early exit.

GNUmakefile
README.markdown

index a0f6983b54602a2c53d8dde0bd2b069cba460a01..1b82c08837056c7deeb1fa215455c57a0da13f8b 100644 (file)
@@ -144,8 +144,8 @@ MAGICDIR := $(patsubst ./%,%,$(THISDIR)/magic)
 
 # Configuration of `find´.
 #
-# By default, `find´ will ignore hidden files, those which begin with a period, and those which are likely to cause problems for `make´.
-FINDRULES := -flags -nohidden -and ! '(' '(' -name '[.-]*' -or -name '*[][*?:|$$%\#;]*' ')' -and -prune ')'
+# By default, `find´ will ignore files which begin with a period and those which are likely to cause problems for `make´.
+FINDRULES := ! '(' '(' -name '[.-]*' -o -name '*[][*?:|$$%\#;]*' ')' -a -prune ')'
 FINDINCLUDERULES := $(FINDRULES)
 
 # The list of parsers for plaintext file types.
@@ -210,10 +210,10 @@ override perenc = $(foreach unencoded,$1,$(call perdec,$(shell $(PRINTF) '%s' $(
 override pathenc = $(foreach path,$1,$(subst $(space),/,$(call perenc,$(subst /, ,$(path)))))
 
 # (overridable) Collect all of the applicable includes from the includes directory.
-sourceincludes := $(shell $(FIND) $(foreach dir,$(INCLUDEDIR),$(call quote,$(dir))) -type f '(' $(FINDRULES) ')')
+sourceincludes := $(shell $(FIND) $(foreach dir,$(INCLUDEDIR),$(call quote,$(dir))) '(' $(FINDRULES) ')' -a -type f)
 
 # (overridable) Collect all of the applicable source files from the source directory, removing any which are also includes.
-sourcefiles := $(filter-out $(sourceincludes),$(shell $(FIND) $(foreach dir,$(SRCDIR),$(call quote,$(dir))) -type f '(' $(FINDRULES) ')'))
+sourcefiles := $(filter-out $(sourceincludes),$(shell $(FIND) $(foreach dir,$(SRCDIR),$(call quote,$(dir))) '(' $(FINDRULES) ')' -a -type f))
 
 ifdef GIT
 ifneq ($(wildcard $(THISDIR)/.git),)
index 95f6954adf6de627ab19e93c620329efb203f852..3801b7eedeb3ca36e6783cc7f10d4020598502b1 100644 (file)
@@ -160,9 +160,9 @@ The following additional variables can be used to control the behaviour
 
 - **`FINDRULES`:**
   Rules to use with `find` when searching for source files.
-  The default ignores hidden files, those that start with a period or
-    hyphen‐minus, and those which contain a pipe, buck, percent,
-    bracket, hash, asterisk, eroteme, semi, or colon.
+  The default ignores files that start with a period or hyphen‐minus
+    and those which contain a hash, buck, percent, asterisk, colon,
+    semi, eroteme, bracket, or pipe.
 
 - **`FINDINCLUDERULES`:**
   Rules to use with `find` when searching for includes (default:
This page took 0.02569 seconds and 4 git commands to generate.