From 59506e56f3c1a1d95e0d465cb43d466c5e7ba49e Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 15 Jun 2022 18:04:45 +0200 Subject: Tweaked parent directory condition --- ls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ls.c') diff --git a/ls.c b/ls.c index fe6ae76..ec03782 100644 --- a/ls.c +++ b/ls.c @@ -30,7 +30,7 @@ int ls(const char * path, struct options opts) if (opts.skip_dots && is_dot) continue; const unsigned int is_self = is_dot && 0 == entry->d_name[1]; - const unsigned int is_up = is_dot && '.' == entry->d_name[1]; + const unsigned int is_up = is_dot && '.' == entry->d_name[1] && 0 == entry->d_name[2]; if (opts.skip_self_and_up && (is_self || is_up)) continue; printf("%s\n", entry->d_name); @@ -60,7 +60,7 @@ int main(int argc, char * argv[]) int res = 0; if (optind >= argc) res |= ls(".", opts); - for (int i = optind; i < argc; ++i) + else for (int i = optind; i < argc; ++i) res |= ls(argv[i], opts); return res; } -- cgit v1.1