From ec871a7370fa2eedd8821c33a2982358e080b2e4 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 16 Nov 2015 14:12:36 +0100 Subject: ls: fix exitcode Once ls is called with a non-existing directory it should exit with a non-zero status. Fix that. Signed-off-by: Sascha Hauer --- commands/ls.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'commands/ls.c') diff --git a/commands/ls.c b/commands/ls.c index 09437afcdf..ce02f16c49 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -124,7 +124,7 @@ out: static int do_ls(int argc, char *argv[]) { - int ret, opt, o; + int ret, opt, o, exitcode = 0; struct stat s; ulong flags = LS_COLUMN; struct string_list sl; @@ -165,6 +165,7 @@ static int do_ls(int argc, char *argv[]) printf("%s: %s: %s\n", argv[0], argv[o], errno_str()); o++; + exitcode = COMMAND_ERROR; continue; } @@ -190,6 +191,7 @@ static int do_ls(int argc, char *argv[]) ret = lstat(argv[o], &s); if (ret) { o++; + exitcode = COMMAND_ERROR; continue; } @@ -197,6 +199,7 @@ static int do_ls(int argc, char *argv[]) ret = ls(argv[o], flags); if (ret) { perror("ls"); + exitcode = COMMAND_ERROR; o++; continue; } @@ -205,7 +208,7 @@ static int do_ls(int argc, char *argv[]) o++; } - return 0; + return exitcode; } BAREBOX_CMD_HELP_START(ls) -- cgit v1.2.3