changeset 1541:28b0987d4952

Test for ls -d from Isaac Dunham, and he pointed out -F also disables symlink following.
author Rob Landley <rob@landley.net>
date Thu, 30 Oct 2014 16:47:29 -0500
parents dabe462d290b
children fd587c7872a9
files tests/ls.test toys/posix/ls.c
diffstat 2 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/ls.test	Thu Oct 30 05:32:54 2014 -0500
+++ b/tests/ls.test	Thu Oct 30 16:47:29 2014 -0500
@@ -37,6 +37,10 @@
           "file1.txt\n" "" ""
 rm -f lstest/slink
 
+ln -s /dev/null/nosuchfile lstest/nosuchfile
+testing "ls with -d - broken softlink" "$IN && ls -d nosuchfile; $OUT" "nosuchfile\n" "" ""
+rm -f lstest/nosuchfile
+
 rm -rf lstest/* && mkdir -p lstest/dir1 && touch lstest/file1.txt
 testing "ls nested recursively" "$IN && ls -R; $OUT" \
           ".:\ndir1\nfile1.txt\n\n./dir1:\n" "" ""
--- a/toys/posix/ls.c	Thu Oct 30 05:32:54 2014 -0500
+++ b/toys/posix/ls.c	Thu Oct 30 16:47:29 2014 -0500
@@ -487,7 +487,7 @@
   // Non-absolute paths are relative to current directory.
   TT.files = dirtree_add_node(0, 0, 0);
   for (s = *toys.optargs ? toys.optargs : noargs; *s; s++) {
-    dt = dirtree_add_node(0, *s, !(toys.optflags & (FLAG_l|FLAG_d))
+    dt = dirtree_add_node(0, *s, !(toys.optflags & (FLAG_l|FLAG_d|FLAG_F))
       || (toys.optflags & (FLAG_L|FLAG_H)));
 
     if (!dt) {