]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: ls: also check a trailing '/.' dereferences a symlink arg
authorSylvestre Ledru <sylvestre@debian.org>
Sat, 6 Jun 2026 06:11:52 +0000 (08:11 +0200)
committerPádraig Brady <P@draigBrady.com>
Sat, 6 Jun 2026 10:35:10 +0000 (11:35 +0100)
* tests/ls/symlink-slash.sh: A symlink-to-directory argument written as
'symlink/.' denotes the directory itself, just like a trailing slash, so
'ls -l symlink/.' must list the directory contents rather than show the
symlink.
See https://github.com/uutils/coreutils/issues/7873
and https://github.com/uutils/coreutils/issues/6467
https://github.com/coreutils/coreutils/pull/280

tests/ls/symlink-slash.sh

index b18d8e917051b84f8ae3e0cde48a592c522d7e9f..b02b4d889f88b0b9d56d9168002db6f0f1a2f12f 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/sh
-# Do dereference a symlink arg if its name is written with a trailing slash.
+# Do dereference a symlink arg if its name is written with a trailing
+# slash, or with a trailing '/.' (both denote the directory itself).
 
 # Copyright (C) 1999-2026 Free Software Foundation, Inc.
 
@@ -27,4 +28,9 @@ set -- $(ls -l symlink/)
 # Prior to fileutils-4.0k, the following would have output '... symlink -> dir'.
 test "$*" = 'total 0' && : || fail=1
 
+# A path ending in '/.' refers to the directory itself, so it must be
+# dereferenced and its (empty) contents listed, not the symlink shown.
+set -- $(ls -l symlink/.)
+test "$*" = 'total 0' && : || fail=1
+
 Exit $fail