Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ls Fix skipping of directories that begin with a '.' in ...



details:   https://anonhg.NetBSD.org/src/rev/c1b6accfb5c7
branches:  trunk
changeset: 935647:c1b6accfb5c7
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jul 07 14:29:06 2020 +0000

description:
Fix skipping of directories that begin with a '.' in -R mode.
It is not enough to avoid displaying the contents of the directory,
we need to set FTS_SKIP to avoid descending into any subdirs too.
Otherwise, if a ".foo" directory has a subdirectory "bar", ls will
descend into bar and display its contents. From Todd Miller

diffstat:

 bin/ls/ls.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 64e918a75382 -r c1b6accfb5c7 bin/ls/ls.c
--- a/bin/ls/ls.c       Tue Jul 07 13:57:20 2020 +0000
+++ b/bin/ls/ls.c       Tue Jul 07 14:29:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ls.c,v 1.76 2017/02/06 21:06:04 rin Exp $      */
+/*     $NetBSD: ls.c,v 1.77 2020/07/07 14:29:06 christos Exp $ */
 
 /*
  * Copyright (c) 1989, 1993, 1994
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)ls.c       8.7 (Berkeley) 8/5/94";
 #else
-__RCSID("$NetBSD: ls.c,v 1.76 2017/02/06 21:06:04 rin Exp $");
+__RCSID("$NetBSD: ls.c,v 1.77 2020/07/07 14:29:06 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -450,8 +450,10 @@
                        break;
                case FTS_D:
                        if (p->fts_level != FTS_ROOTLEVEL &&
-                           p->fts_name[0] == '.' && !f_listdot)
+                           p->fts_name[0] == '.' && !f_listdot) {
+                               (void)fts_set(ftsp, p, FTS_SKIP);
                                break;
+                       }
 
                        /*
                         * If already output something, put out a newline as



Home | Main Index | Thread Index | Old Index