From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] hush: setting variables may fail
Date: Fri, 16 May 2014 15:13:06 +0200 [thread overview]
Message-ID: <1400245986-1988-1-git-send-email-s.hauer@pengutronix.de> (raw)
In case of device parameters setting variables may fail. return
the result of set_local_var so that the user has a chance to detect
the failure with $?.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/hush.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/common/hush.c b/common/hush.c
index 1447fdb..e6479b2 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -734,6 +734,7 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi)
char *p;
glob_t globbuf = {};
int ret;
+ int rcode;
# if __GNUC__
/* Avoid longjmp clobbering */
(void) &i;
@@ -753,8 +754,6 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi)
child = &pi->progs[0];
if (child->group) {
- int rcode;
-
debug("non-subshell grouping\n");
rcode = run_list_real(ctx, child->group);
@@ -789,7 +788,9 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi)
free(name);
p = insert_var_value(child->argv[i]);
- set_local_var(p, export_me);
+ rcode = set_local_var(p, export_me);
+ if (rcode)
+ return 1;
if (p != child->argv[i])
free(p);
@@ -798,7 +799,9 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi)
}
for (i = 0; is_assignment(child->argv[i]); i++) {
p = insert_var_value(child->argv[i]);
- set_local_var(p, 0);
+ rcode = set_local_var(p, 0);
+ if (rcode)
+ return 1;
if (p != child->argv[i]) {
child->sp--;
@@ -808,7 +811,6 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi)
if (child->sp) {
char * str = NULL;
struct p_context ctx1;
- int rcode;
str = make_string((child->argv + i));
rcode = parse_string_outer(&ctx1, str, FLAG_EXIT_FROM_LOOP | FLAG_REPARSING);
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2014-05-16 13:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1400245986-1988-1-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