[git commit master 1/1] ls: fix handling of symlinks by option -1

Denys Vlasenko vda.linux at googlemail.com
Sat Mar 12 02:12:36 UTC 2011


commit: http://git.busybox.net/busybox/commit/?id=ea684c6aaf23ead57fac74c3ceaa651c1ae625ec
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/ls.c     |    6 ++++--
 testsuite/ls.tests |   10 ++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/coreutils/ls.c b/coreutils/ls.c
index 19c868c..847fdec 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -1,6 +1,5 @@
 /* vi: set sw=4 ts=4: */
 /*
- * tiny-ls.c version 0.1.0: A minimalist 'ls'
  * Copyright (C) 1996 Brian Candler <B.Candler at pobox.com>
  *
  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
@@ -1145,7 +1144,10 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
 	do {
 		cur = my_stat(*argv, *argv,
 			/* follow links on command line unless -l, -s or -F: */
-			!((all_fmt & (STYLE_LONG|LIST_BLOCKS)) || (option_mask32 & OPT_F))
+			!((all_fmt & STYLE_MASK) == STYLE_LONG
+			  || (all_fmt & LIST_BLOCKS)
+			  || (option_mask32 & OPT_F)
+			)
 			/* ... or if -H: */
 			|| (option_mask32 & OPT_H)
 		);
diff --git a/testsuite/ls.tests b/testsuite/ls.tests
index 1669579..e228465 100755
--- a/testsuite/ls.tests
+++ b/testsuite/ls.tests
@@ -251,6 +251,16 @@ test x"$CONFIG_UNICODE_SUPPORT" = x"y" \
 0110_5.3.2__U+FFFF_=_ef_bf_bf_=_"?"_______________________________________|
 ' "" ""
 
+rm -rf ls.testdir 2>/dev/null
+mkdir ls.testdir || exit 1
+
+# testing "test name" "command" "expected result" "file input" "stdin"
+
+testing "ls symlink_to_dir" \
+"touch ls.testdir/A ls.testdir/B; ln -s ls.testdir ls.link; ls ls.link; ls -1 ls.link/; ls -1 ls.link; rm -f ls.link" \
+"A\nB\nA\nB\nA\nB\n" \
+"" ""
+
 # Clean up
 rm -rf ls.testdir 2>/dev/null
 
-- 
1.7.3.4



More information about the busybox-cvs mailing list