diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-08-10 12:54:04 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-08-10 20:59:58 +0200 |
commit | 4d902142a5691cd9641b2ad468eb5407c897b433 (patch) | |
tree | c7d8b7b9341f21e97f46df81dd80fac04d215fae /common/hush.c | |
parent | 16edced39ecf4c316179b72c01af249f85b36218 (diff) | |
download | barebox-4d902142a5691cd9641b2ad468eb5407c897b433.tar.gz barebox-4d902142a5691cd9641b2ad468eb5407c897b433.tar.xz |
hush: catch errors from execute_binfmt
execute_binfmt may return negative return values which hush interprets
as 'exit'. Catch this and print an error message instead.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/hush.c')
-rw-r--r-- | common/hush.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/common/hush.c b/common/hush.c index 288114c6cf..61aac13d1b 100644 --- a/common/hush.c +++ b/common/hush.c @@ -785,12 +785,17 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi) remove_quotes(globbuf.gl_pathc, globbuf.gl_pathv); - if (!strcmp(globbuf.gl_pathv[0], "getopt")) + if (!strcmp(globbuf.gl_pathv[0], "getopt")) { ret = builtin_getopt(ctx, child, globbuf.gl_pathc, globbuf.gl_pathv); - else if (!strcmp(globbuf.gl_pathv[0], "exit")) + } else if (!strcmp(globbuf.gl_pathv[0], "exit")) { ret = builtin_exit(ctx, child, globbuf.gl_pathc, globbuf.gl_pathv); - else + } else { ret = execute_binfmt(globbuf.gl_pathc, globbuf.gl_pathv); + if (ret < 0) { + printf("%s: %s\n", globbuf.gl_pathv[0], strerror(-ret)); + ret = 127; + } + } globfree(&globbuf); |