mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] hush: catch errors from execute_binfmt
Date: Fri, 10 Aug 2012 12:58:17 +0200	[thread overview]
Message-ID: <1344596297-10781-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1344596297-10781-1-git-send-email-s.hauer@pengutronix.de>

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>
---
 common/hush.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/hush.c b/common/hush.c
index 288114c..61aac13 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);
 
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2012-08-10 10:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 10:58 [PATCH] fix hush 'exit' Sascha Hauer
2012-08-10 10:58 ` [PATCH 1/2] hush: Make exit a shell builtin Sascha Hauer
2012-08-10 10:58 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1344596297-10781-3-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox