ls: Don't show directory name with single directory operand
This fixes the issueb107489bf2
tried to fix, but doesn't break -R (whichbb83eade39
tried to fix).
This commit is contained in:
parent
e8e9b97baf
commit
ea03da0bda
5
ls.c
5
ls.c
|
@ -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);
|
||||
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user