summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-11-16 14:12:36 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-11-17 11:57:33 +0100
commitec871a7370fa2eedd8821c33a2982358e080b2e4 (patch)
treeef3e4112807f8ae5cd955f0bb36b5850d82a5149
parent405c6e09dd4b7179573a64563be95ca47686c1ef (diff)
downloadbarebox-ec871a7370fa2eedd8821c33a2982358e080b2e4.tar.gz
barebox-ec871a7370fa2eedd8821c33a2982358e080b2e4.tar.xz
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 <s.hauer@pengutronix.de>
-rw-r--r--commands/ls.c7
1 files changed, 5 insertions, 2 deletions
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)