I pushed this one adding some tests after thinking about the infinite
loop a bit longer. It tests the rest of the options independently,
which would have previously had an infinite loop.

There is also another invocation which would have not had an infinite
loop, even with the bug, due to its documented behavior.

--- 8< ---

* tests/misc/realpath.sh: Test the flags supported by 'realpath' that
would previously infinite loop before commit b66f3e4e2 (realpath: fix an
infinite loop when resolving symbolic links, 2026-09-25). Test an
invocation which would avoid the infinite loop by not touching the file.
---
 tests/misc/realpath.sh | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tests/misc/realpath.sh b/tests/misc/realpath.sh
index 393ab1424..3ef5f9b39 100755
--- a/tests/misc/realpath.sh
+++ b/tests/misc/realpath.sh
@@ -139,13 +139,21 @@ test "$(realpath -e noread/)" = "$(realpath .)/noread" || 
fail=1
 # system ran out of memory.
 ln -s loop/a loop || framework_failure_
 vm=$(get_min_ulimit_v_ realpath .) && {
-  (ulimit -v $(($vm+6000)) &&
-     returns_ 1 timeout 10 realpath loop >out 2>err) || fail=1
   cat <<EOF >exp || framework_failure_
 realpath: loop: $ELOOP
 EOF
-  compare /dev/null out || fail=1
-  compare exp err || fail=1
+  for opt in '' -E -e -m -s -L -P; do
+    (ulimit -v $(($vm+6000)) &&
+       returns_ 1 timeout 10 realpath $opt loop >out 2>err) || fail=1
+    compare /dev/null out || fail=1
+    compare exp err || fail=1
+  done
 }
 
+# This one doesn't need to touch the file.
+echo "$(realpath .)"/loop >exp || framework_failure_
+realpath -ms loop >out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
 Exit $fail
-- 
2.55.0


Reply via email to