On Sun, Dec 07, 2014 at 10:40:42PM +0000, Michael Forney wrote: > --- > ls.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/ls.c b/ls.c > index b48391b..90193cc 100644 > --- a/ls.c > +++ b/ls.c > @@ -21,6 +21,7 @@ typedef struct { > off_t size; > time_t mtime; > ino_t ino; > + int isdir; > } Entry; > > static int entcmp(const void *, const void *); > @@ -117,7 +118,7 @@ entcmp(const void *va, const void *vb) > static void > ls(Entry *ent) > { > - if (S_ISDIR(ent->mode) && !dflag) { > + if (ent->isdir && !dflag) { > lsdir(ent->name); > } else { > output(ent); > @@ -191,6 +192,7 @@ mkent(Entry *ent, char *path, int dostat) > ent->size = st.st_size; > ent->mtime = st.st_mtime; > ent->ino = st.st_ino; > + ent->isdir = S_ISLNK(ent->mode) && stat(path, &st) == 0 && > S_ISDIR(st.st_mode);
Whoops, this should also have S_ISDIR(ent->mode) || ... Will send a new patch shortly.