From: Wolfgang Denk Date: Mon, 14 Feb 2011 20:11:37 +0100 Subject: [U-Boot] [PATCH 2/2] hush: Fix return code when using 'exit' in control structures In-Reply-To: <1297710697-13872-1-git-send-email-wd@denx.de> References: <1297710697-13872-1-git-send-email-wd@denx.de> Message-ID: <1297710697-13872-2-git-send-email-wd@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This fixes cases like this one, there hush used to return 0 : => if foo ; then do something ; exit 1 ; fi ; echo RC=$? Unknown command 'foo' - try 'help' RC=1 Adapted from Barebox commit 2477fb1 From: Sascha Hauer Date: Tue, 23 Mar 2010 15:33:43 +0100 Signed-off-by: Wolfgang Denk --- common/hush.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/hush.c b/common/hush.c index c6f8392..32561a7 100644 --- a/common/hush.c +++ b/common/hush.c @@ -1938,7 +1938,7 @@ static int run_list_real(struct pipe *pi) #else if (rcode < -1) { last_return_code = -rcode - 2; - return -2; /* exit */ + return rcode; /* exit */ } last_return_code=(rcode == 0) ? 0 : 1; #endif @@ -3184,7 +3184,7 @@ int parse_stream_outer(struct in_str *inp, int flag) free_pipe_list(ctx.list_head, 0); continue; } - if (code == -2) { /* exit */ + if (code < -1) { /* exit */ b_free(&temp); code = 0; /* XXX hackish way to not allow exit from main loop */ -- 1.7.4