Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46CBCC433EF for ; Fri, 31 Dec 2021 16:17:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 68705835EA; Fri, 31 Dec 2021 17:15:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="oiDPAwyS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 30B7683662; Fri, 31 Dec 2021 17:15:19 +0100 (CET) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1B26A83681 for ; Fri, 31 Dec 2021 17:14:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=francis.laniel@amarulasolutions.com Received: by mail-wr1-x434.google.com with SMTP id i22so56640551wrb.13 for ; Fri, 31 Dec 2021 08:14:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JWW/iY8mNBTsULocT4DV+5v5B6zF0ApwpzilqS+JPYI=; b=oiDPAwySSdc3wo5KY5Y8+VDCWqeoIz+i/syMu3qmdPvODd2JN9w+hpnnroDzRyaqid l2v8AWr/xA5NmnEGx+g6aS1flHy/NZLf1JiQuopJZEFOGPvWWj3VPa+kZgpHmfXALeHx 5miJvWqtRsAlUQlHEseX/HJid0Wg4pcNSb1J8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JWW/iY8mNBTsULocT4DV+5v5B6zF0ApwpzilqS+JPYI=; b=iy3cdgZc1VDJOYvWhqci14oaEf0ZO1JiW+kX/zyA+FvxZrzoHs8lZ3X3R/bYqArg/A mKdsbAUsFW/D9CxLne3guS7iiDpIflpxQsLGE2YHZbWgr3Zskm4vPykHL7ijjVWMMqaI +Hc7m6U8pvw6zJEvU7FnoLrH/iWH4PFTN4vh37/4J/3aulNW96iVgncf+deTFw3Naugk QOsWtnCBvU/aqC7iGcuYu+rXF4POwvI09ZagLKSAoMsJ04Q9z1MWmPgVeeTlU7NnjmKa pROJM1zMOiLO2SEqSebxPVykg34WEhgBCNbBeESpgYs0Zug3u+4+S7dxuEMKiveGYn/z lrHQ== X-Gm-Message-State: AOAM532jsLLC2LpfTnrp79bzbvTZOA/dvG/U7if0x4wU6vjoqw8umt3U b91hEqqvcjvuDn4Q4dpkYcUZC/iQeO6OAg== X-Google-Smtp-Source: ABdhPJwFSdCYUtGW6JvrfzTQnlep7W8w8Hs6vDAUjG52GnjNEzfq48mvFAPTTN7t+QWY8p3ZY/V4HQ== X-Received: by 2002:adf:f681:: with SMTP id v1mr30411524wrp.229.1640967255689; Fri, 31 Dec 2021 08:14:15 -0800 (PST) Received: from pwmachine.home ([2a01:cb14:983:1f00:eef7:8bf8:8ee0:cb1a]) by smtp.gmail.com with ESMTPSA id f6sm31855522wmq.6.2021.12.31.08.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 08:14:15 -0800 (PST) From: Francis Laniel To: u-boot@lists.denx.de Cc: Marek Behun , Michael Nazzareno Trimarchi , Simon Glass , Wolfgang Denk , Harald Seiler , Francis Laniel Subject: [RFC PATCH v1 18/21] cli: hush_2021: Enable if keyword. Date: Fri, 31 Dec 2021 17:13:24 +0100 Message-Id: <20211231161327.24918-19-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211231161327.24918-1-francis.laniel@amarulasolutions.com> References: <20211231161327.24918-1-francis.laniel@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean This commit adds support for "if then else" construct both for command line interface and through run_command(). Signed-off-by: Francis Laniel --- common/cli_hush_2021_upstream.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/common/cli_hush_2021_upstream.c b/common/cli_hush_2021_upstream.c index d1f76d4df5..5c783494d1 100644 --- a/common/cli_hush_2021_upstream.c +++ b/common/cli_hush_2021_upstream.c @@ -3951,7 +3951,6 @@ static void debug_print_tree(struct pipe *pi, int lvl) [PIPE_OR ] = "OR" , [PIPE_BG ] = "BG" , }; -#ifndef __U_BOOT__ static const char *RES[] = { [RES_NONE ] = "NONE" , # if ENABLE_HUSH_IF @@ -3981,7 +3980,6 @@ static void debug_print_tree(struct pipe *pi, int lvl) [RES_XXXX ] = "XXXX" , [RES_SNTX ] = "SNTX" , }; -#endif /* !__U_BOOT__ */ static const char *const CMDTYPE[] = { "{}", "()", @@ -3999,10 +3997,8 @@ static void debug_print_tree(struct pipe *pi, int lvl) lvl*2, "", pin, pi->num_cmds, -#ifdef __U_BOOT__ (IF_HAS_KEYWORDS(pi->pi_inverted ? "! " :) ""), RES[pi->res_word], -#endif /* !__U_BOOT__ */ pi->followup, PIPE[pi->followup] ); prn = 0; @@ -9792,6 +9788,7 @@ static NOINLINE int run_pipe(struct pipe *pi) rcode = 1; /* exitcode if redir failed */ #ifndef __U_BOOT__ if (setup_redirects(command, &squirrel) == 0) { +#endif /* !__U_BOOT__ */ debug_printf_exec(": run_list\n"); //FIXME: we need to pass squirrel down into run_list() //for SH_STANDALONE case, or else this construct: @@ -9800,10 +9797,11 @@ static NOINLINE int run_pipe(struct pipe *pi) //and in SH_STANDALONE mode, "find" is not execed, //therefore CLOEXEC on saved fd does not help. rcode = run_list(command->group) & 0xff; +#ifndef __U_BOOT__ } restore_redirects(squirrel); - IF_HAS_KEYWORDS(if (pi->pi_inverted) rcode = !rcode;) #endif /* !__U_BOOT__ */ + IF_HAS_KEYWORDS(if (pi->pi_inverted) rcode = !rcode;) debug_leave(); debug_printf_exec("run_pipe: return %d\n", rcode); return rcode; @@ -10318,12 +10316,12 @@ static int run_list(struct pipe *pi) break; if (G_flag_return_in_progress == 1) break; +#endif /* !__U_BOOT__ */ IF_HAS_KEYWORDS(rword = pi->res_word;) debug_printf_exec(": rword=%d cond_code=%d last_rword=%d\n", rword, cond_code, last_rword); -#endif /* !__U_BOOT__ */ sv_errexit_depth = G.errexit_depth; if ( #if ENABLE_HUSH_IF -- 2.25.1