From 82671e1ed5f06e016398f3d2de5f3c2ba388713d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 30 Oct 2014 16:47:29 -0500 Subject: Test for ls -d from Isaac Dunham, and he pointed out -F also disables symlink following. --- tests/ls.test | 4 ++++ toys/posix/ls.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/ls.test b/tests/ls.test index d052f13a..9866eb78 100644 --- a/tests/ls.test +++ b/tests/ls.test @@ -37,6 +37,10 @@ testing "ls softlink - long listing" "$IN && ls -l slink | awk '{ print \$NF }' "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" "" "" diff --git a/toys/posix/ls.c b/toys/posix/ls.c index 37da4497..d1a26ee1 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -487,7 +487,7 @@ void ls_main(void) // 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) { -- cgit v1.2.3