sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit c4c45c96371fa5a47921c95861de67e5f0cb569b
parent bb796334806f1920915744e1bfa986f08623978f
Author: Quentin Rameau <quinq@fifth.space>
Date:   Thu Feb 18 12:06:21 +0100

ls: do not exit when a directory isn't accessible

Just print a warning and process next item instead,
and return 1 to report this error.

Diffstat:
ls.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/ls.c b/ls.c @@ -32,6 +32,7 @@ static struct { ino_t ino; } tree[PATH_MAX]; +static int ret = 0; static int Aflag = 0; static int aflag = 0; static int cflag = 0; @@ -247,8 +248,11 @@ lsdir(const char *path, const struct entry *dir) size_t i, n = 0; char prefix[PATH_MAX]; - if (!(dp = opendir(dir->name))) - eprintf("opendir %s:", dir->name); + if (!(dp = opendir(dir->name))) { + ret = 1; + weprintf("opendir %s:", dir->name); + return; + } if (chdir(dir->name) < 0) eprintf("chdir %s:", dir->name); @@ -474,5 +478,5 @@ main(int argc, char *argv[]) free(dents); } - return fshut(stdout, "<stdout>"); + return (fshut(stdout, "<stdout>") | ret); }