From patchwork Mon Feb 14 19:11:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Denk X-Patchwork-Id: 83151 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E0D64B7103 for ; Tue, 15 Feb 2011 06:12:05 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AC2842807D; Mon, 14 Feb 2011 20:11:57 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XgiK22VUcjIL; Mon, 14 Feb 2011 20:11:57 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 30AC228091; Mon, 14 Feb 2011 20:11:56 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 08FE428089 for ; Mon, 14 Feb 2011 20:11:54 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d4b58ivbKLwC for ; Mon, 14 Feb 2011 20:11:52 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by theia.denx.de (Postfix) with ESMTP id 1544D2807C for ; Mon, 14 Feb 2011 20:11:48 +0100 (CET) Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id E32F0186DEF3 for ; Mon, 14 Feb 2011 20:11:47 +0100 (CET) X-Auth-Info: v2rZCHSSajIfVJwHGSsbMXp9ahr+Dvt2d2yxeh4VF6I= Received: from diddl.denx.de (host-80-81-18-216.customer.m-online.net [80.81.18.216]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id E23771C00127 for ; Mon, 14 Feb 2011 20:11:47 +0100 (CET) Received: from gemini.denx.de (gemini.denx.de [10.0.0.2]) by diddl.denx.de (Postfix) with ESMTP id C91123096C20 for ; Mon, 14 Feb 2011 20:11:47 +0100 (CET) Received: by gemini.denx.de (Postfix, from userid 500) id BB79C151B54; Mon, 14 Feb 2011 20:11:47 +0100 (CET) From: Wolfgang Denk To: u-boot@lists.denx.de Date: Mon, 14 Feb 2011 20:11:37 +0100 Message-Id: <1297710697-13872-2-git-send-email-wd@denx.de> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1297710697-13872-1-git-send-email-wd@denx.de> References: <1297710697-13872-1-git-send-email-wd@denx.de> Subject: [U-Boot] [PATCH 2/2] hush: Fix return code when using 'exit' in control structures X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@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 */