[hackers] [sbase] Revert "Fix showing directories when -R flag is set in ls(1)" || Michael Forney

From: <git_AT_suckless.org>
Date: Sat, 9 Jul 2016 11:09:57 +0200 (CEST)

commit b91b9e79ec3b4f0d19c4697acefe01b0f4cc0d6e
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Sat May 14 18:56:50 2016 -0700
Commit: sin <sin_AT_2f30.org>
CommitDate: Sat Jul 9 10:09:50 2016 +0100

    Revert "Fix showing directories when -R flag is set in ls(1)"
    
    This reverts commit bb83eade399e7d6f3642ae3a5e2cdebab6f222a1.
    
    This commit causes the loop through dents at the end of main to
    continue past the end of the dents array, causing a crash when
    called with multiple directory arguments.

diff --git a/ls.c b/ls.c
index 8cc285b..a59cc0a 100644
--- a/ls.c
+++ b/ls.c
_AT_@ -278,7 +278,7 @@ lsdir(const char *path, const struct entry *dir)
         if (!Uflag)
                 qsort(ents, n, sizeof(*ents), entcmp);
 
- if (ds++)
+ if (ds > 1 && (path[0] || dir->name[0] != '.'))
                 printf("%s:\n", dir->name);
         for (i = 0; i < n; i++)
                 output(&ents[i]);
Received on Sat Jul 09 2016 - 11:09:57 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 09 2016 - 11:13:30 CEST