summaryrefslogtreecommitdiffstats
path: root/bin/ls/ls.c
diff options
context:
space:
mode:
authorsef <sef@FreeBSD.org>1997-09-18 06:42:27 +0000
committersef <sef@FreeBSD.org>1997-09-18 06:42:27 +0000
commit2e215bb009cecad3f87477d63b57b7790d49b72e (patch)
tree637d97a00f3f41b8864c81221630eec20c2b7548 /bin/ls/ls.c
parentce8df1cd4a99de80e927c5b1489abd07df57d0dd (diff)
downloadFreeBSD-src-2e215bb009cecad3f87477d63b57b7790d49b72e.zip
FreeBSD-src-2e215bb009cecad3f87477d63b57b7790d49b72e.tar.gz
Fix sorting of directories when doing '-d'.
PR: bin/4558 Submitted by: Keith Bostic
Diffstat (limited to 'bin/ls/ls.c')
-rw-r--r--bin/ls/ls.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 7f4e148..768af2d 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
#else
static const char rcsid[] =
- "$Id: ls.c,v 1.15 1997/08/07 15:33:47 steve Exp $";
+ "$Id: ls.c,v 1.16 1997/08/07 22:28:23 steve Exp $";
#endif
#endif /* not lint */
@@ -528,16 +528,12 @@ mastercmp(a, b)
if (a_info == FTS_NS || b_info == FTS_NS)
return (namecmp(*a, *b));
- if (a_info == b_info)
- return (sortfcn(*a, *b));
-
- if ((*a)->fts_level == FTS_ROOTLEVEL)
+ if (a_info != b_info &&
+ (*a)->fts_level == FTS_ROOTLEVEL && !f_listdir) {
if (a_info == FTS_D)
return (1);
- else if (b_info == FTS_D)
+ if (b_info == FTS_D)
return (-1);
- else
- return (sortfcn(*a, *b));
- else
- return (sortfcn(*a, *b));
+ }
+ return (sortfcn(*a, *b));
}
OpenPOWER on IntegriCloud