summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-06-03 18:30:09 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-06-03 18:30:09 -0400
commit9e408d4bb50cb7c4e9d0a007b95f9fb9d32a16d0 (patch)
tree582082976f6d971928ccaed37e11d616e5378a98 /src/eval.c
parent6e4c3893ae4e053d571ee538f8b4dc4e6cfce658 (diff)
downloadbfs-9e408d4bb50cb7c4e9d0a007b95f9fb9d32a16d0.tar.xz
Make ELOOP an error again, except for -xtype.3.3.1
POSIX requires an error if (for example) -L encounters a symlink loop. The GNU find change was restricted to -xtype, so add a manual ELOOP test to eval_xtype() for compatibility. This reverts commit 470589cbd9ca3e73d8c01ac3a96cbc065179dcc5. Link: https://savannah.gnu.org/bugs/?19605
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c
index 0495207..cef766d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -999,6 +999,13 @@ bool eval_xtype(const struct bfs_expr *expr, struct bfs_eval *state) {
const struct BFTW *ftwbuf = state->ftwbuf;
enum bfs_stat_flags flags = ftwbuf->stat_flags ^ (BFS_STAT_NOFOLLOW | BFS_STAT_TRYFOLLOW);
enum bfs_type type = bftw_type(ftwbuf, flags);
+
+ // GNU find treats ELOOP as a broken symbolic link for -xtype l
+ // (but not -L -type l)
+ if ((flags & BFS_STAT_TRYFOLLOW) && type == BFS_ERROR && errno == ELOOP) {
+ type = BFS_LNK;
+ }
+
if (type == BFS_ERROR) {
eval_report_error(state);
return false;