commit 6ab5e500cd9dc0afd5c3f5e9c9af7cb3ac532d91
parent 3802e80c2b084088b5f19ef2b532a13c042e3096
Author: phoebos <ben@bvnf.space>
Date: Tue, 21 Sep 2021 10:16:28 +0100
ls: fix setting ret_val
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/ls.c b/ls.c
@@ -123,10 +123,13 @@ main(int argc, char **argv) {
if(!isatty(1))
flags |= FLAG_1;
- if (argc == optind)
- ret_val = ls(".", flags);
+ if (argc == optind) {
+ if (ls(".", flags) != 0)
+ ret_val = 1;
+ }
else while (*++argv)
- ret_val = ls(*argv, flags);
+ if (ls(*argv, flags) != 0)
+ ret_val = 1;
if (!(flags & FLAG_1))
puts(""); /* final newline */