From patchwork Fri May 30 20:41:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 354340 X-Patchwork-Delegate: trini@ti.com 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 DF6C21400F6 for ; Sat, 31 May 2014 06:42:38 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C94EB4A03E; Fri, 30 May 2014 22:42:34 +0200 (CEST) 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 AGakaL1w9zMN; Fri, 30 May 2014 22:42:34 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 21B774A03F; Fri, 30 May 2014 22:42:25 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B162C4A032 for ; Fri, 30 May 2014 22:42:19 +0200 (CEST) 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 QGcW7-XI8Dtb for ; Fri, 30 May 2014 22:42:15 +0200 (CEST) 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-vc0-f201.google.com (mail-vc0-f201.google.com [209.85.220.201]) by theia.denx.de (Postfix) with ESMTPS id 8B6B94B817 for ; Fri, 30 May 2014 22:42:04 +0200 (CEST) Received: by mail-vc0-f201.google.com with SMTP id ij19so522043vcb.4 for ; Fri, 30 May 2014 13:42:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5mG5yZKnAmRb9aNgrwK5Gz4uobGTSAaoUikHrsP/pdg=; b=W5DY/Dj0PynwESuls/7ZNBieT/5h/2VeiRX0iZmzelKfNCBc9sCQZzmyG1IYCKlxae TUiE6MQ0XUCVVcm5YWAiGzQV5n7qA4eyqihLwp7EOIFzDNrA5i+tvIb6TecpM9ALleqM DIm1zY7DxHdAAjrBTiwOLOtnQ8amQRT/vrl5TNBcWKdeWRABHkv1sHY/jrla9Wacn0xS 4wHJTSNixg/HaentTpzcTkwJAuUkWkdXRKqnBcUGFbHI81K2huBwReEoNLxSBWQQtBm0 0DjpN6skcBuwUbxJJiwdrZ5CkW9wNL/lOAxeyhLfK0tVFx8hzVhnzhzpNnFhy45MdDeX +cEQ== X-Gm-Message-State: ALoCoQmNS5ycD7qpnFjfIULHkXHewzYriGA3PYiwaenjzNAvI6uFXC88mZJivtcLSHF2HTsTS4C5 X-Received: by 10.236.88.239 with SMTP id a75mr718766yhf.50.1401482522761; Fri, 30 May 2014 13:42:02 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id c22si358046yhe.1.2014.05.30.13.42.02 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 May 2014 13:42:02 -0700 (PDT) Received: from kaki.bld.corp.google.com (kaki.bld.corp.google.com [172.29.216.32]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 9D4D15A4647; Fri, 30 May 2014 13:42:02 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 46A9C220FCA; Fri, 30 May 2014 14:42:02 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Fri, 30 May 2014 14:41:50 -0600 Message-Id: <1401482511-9647-4-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: <1401482511-9647-1-git-send-email-sjg@chromium.org> References: <1401482511-9647-1-git-send-email-sjg@chromium.org> Cc: Tom Rini Subject: [U-Boot] [PATCH v2 3/4] Fix hush to give the correct return code for a simple command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 When a simple command like 'false' is provided, hush should return the result of that command. However, hush only does this if the FLAG_EXIT_FROM_LOOP flag is provided. Without this flag, hush will happily execute the empty string command immediate after 'false' and then return a success code. This behaviour does not seem very useful, and requiring the flag also seems wrong, since it means that hush will execute only the first command in a sequence. Add a check for empty string and fall out of the loop in that case. That at least fixes the simple command case. This is a change in behaviour but it is unlikely that the old behaviour would be considered correct in any case. Reported-by: Stefan Herbrechtsmeier Signed-off-by: Simon Glass --- Changes in v2: None common/cli_hush.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/cli_hush.c b/common/cli_hush.c index 0f069b0..e0c436f 100644 --- a/common/cli_hush.c +++ b/common/cli_hush.c @@ -3215,7 +3215,9 @@ static int parse_stream_outer(struct in_str *inp, int flag) free_pipe_list(ctx.list_head,0); } b_free(&temp); - } while (rcode != -1 && !(flag & FLAG_EXIT_FROM_LOOP)); /* loop on syntax errors, return on EOF */ + /* loop on syntax errors, return on EOF */ + } while (rcode != -1 && !(flag & FLAG_EXIT_FROM_LOOP) && + (inp->peek != static_peek || b_peek(inp))); #ifndef __U_BOOT__ return 0; #else