Fix showing directories when -R flag is set in ls(1)

Here's a better version of the patch.
When the R flag is used with a single directory, the given directory name is
omitted. With multiple directories each directory name is listed.
Directories that start with './' and '../' are now also printed.
This commit is contained in:
pekka.jylha.ollila@gmail.com 2016-02-17 20:56:39 +02:00 committed by sin
parent b97839751b
commit bb83eade39

2
ls.c
View File

@ -270,7 +270,7 @@ lsdir(const char *path, const struct entry *dir)
if (!Uflag) if (!Uflag)
qsort(ents, n, sizeof(*ents), entcmp); qsort(ents, n, sizeof(*ents), entcmp);
if (ds > 1 && (path[0] || dir->name[0] != '.')) if (ds++)
printf("%s:\n", dir->name); printf("%s:\n", dir->name);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
output(&ents[i]); output(&ents[i]);