[hackers] [sbase] ls: Don't show directory name with single directory operand || Michael Forney

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

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

    ls: Don't show directory name with single directory operand
    
    This fixes the issue b107489bf2cda579ca53551206270b9eee80c059 tried
    to fix, but doesn't break -R (which
    bb83eade399e7d6f3642ae3a5e2cdebab6f222a1 tried to fix).

diff --git a/ls.c b/ls.c
index 55dfe40..42811c5 100644
--- a/ls.c
+++ b/ls.c
_AT_@ -53,6 +53,7 @@ static int Uflag = 0;
 static int uflag = 0;
 static int first = 1;
 static char sort = 0;
+static int showdirs;
 
 static void ls(const char *, const struct entry *, int);
 
_AT_@ -277,7 +278,7 @@ lsdir(const char *path, const struct entry *dir)
         if (!Uflag)
                 qsort(ents, n, sizeof(*ents), entcmp);
 
- if (path[0] || dir->name[0] != '.')
+ if (path[0] || showdirs)
                 printf("%s:\n", dir->name);
         for (i = 0; i < n; i++)
                 output(&ents[i]);
_AT_@ -469,6 +470,8 @@ main(int argc, char *argv[])
                         }
                 }
 
+ showdirs = ds > 1 || (ds && fs);
+
                 qsort(fents, fs, sizeof(ent), entcmp);
                 qsort(dents, ds, sizeof(ent), entcmp);
 
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:35 CEST