On 2016-02-14 13:59, tty0 wrote:
---
ls.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ls.c b/ls.c
index 3611a87..36a1fb6 100644
--- a/ls.c
+++ b/ls.c
@@ -52,6 +52,7 @@ static int Uflag = 0;
static int uflag = 0;
static int first = 1;
static char sort = 0;
+static size_t ds;
static void ls(const char *, const struct entry *, int);
@@ -269,7 +270,7 @@ lsdir(const char *path, const struct entry *dir)
if (!Uflag)
qsort(ents, n, sizeof(*ents), entcmp);
- if (path[0] || dir->name[0] != '.')
+ if (ds > 1 && (path[0] || dir->name[0] != '.'))
printf("%s:\n", dir->name);
for (i = 0; i < n; i++)
output(&ents[i]);
@@ -360,7 +361,7 @@ int
main(int argc, char *argv[])
{
struct entry ent, *dents, *fents;
- size_t i, ds, fs;
+ size_t i, fs;
ARGBEGIN {
case '1':
From 1bdf48eb62d2e4223e9e859e02fc193eb7b08edc Mon Sep 17 00:00:00 2001
From: tty0
Date: Sun, 14 Feb 2016 15:48:03 -0600
Subject: [PATCH] ls: only display directory headers when more than one
directory is specified
---
ls.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ls.c b/ls.c
index 3611a87..36a1fb6 100644
--- a/ls.c
+++ b/ls.c
@@ -52,6 +52,7 @@ static int Uflag = 0;
static int uflag = 0;
static int first = 1;
static char sort = 0;
+static size_t ds;
static void ls(const char *, const struct entry *, int);
@@ -269,7 +270,7 @@ lsdir(const char *path, const struct entry *dir)
if (!Uflag)
qsort(ents, n, sizeof(*ents), entcmp);
- if (path[0] || dir->name[0] != '.')
+ if (ds > 1 && (path[0] || dir->name[0] != '.'))
printf("%s:\n", dir->name);
for (i = 0; i < n; i++)
output(&ents[i]);
@@ -360,7 +361,7 @@ int
main(int argc, char *argv[])
{
struct entry ent, *dents, *fents;
- size_t i, ds, fs;
+ size_t i, fs;
ARGBEGIN {
case '1':
--
1.9.1