From mboxrd@z Thu Jan 1 00:00:00 1970 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 1E1DAC433EF for ; Thu, 16 Jun 2022 22:41:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9EA5984451; Fri, 17 Jun 2022 00:41:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (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="SpYoNFa5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 86FE784396; Fri, 17 Jun 2022 00:40:54 +0200 (CEST) Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (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 04DC084487 for ; Fri, 17 Jun 2022 00:33:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=francis.laniel@amarulasolutions.com Received: by mail-wm1-x32c.google.com with SMTP id l2-20020a05600c4f0200b0039c55c50482so3514656wmq.0 for ; Thu, 16 Jun 2022 15:33:44 -0700 (PDT) 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=tMca0HYdqz8Dk8Nq6WU76Gc+CmdDyE1Jt7QX+uE9IOU=; b=SpYoNFa5eW6csE5yfZEzYeHKkxmtgZemT0QR6MB66vcwZbZnp+Xl0LOiT0Nzn7vYR8 1/N3ncBu5EQMliaHCSrEiEEHI6Yffl2OR7hxzGO5AF0wtWRYX37+alXa7w1l8tUlk/28 jLUOH1GW0NpItsEypv3T1JhQ8xlWaPvZzOot4= 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=tMca0HYdqz8Dk8Nq6WU76Gc+CmdDyE1Jt7QX+uE9IOU=; b=IhoFeYymjKxBDLFUQthR5pkDXxX4zaU93WNznv7SSdCTKQbvCjke6oDhGw0rFGUwcQ cnAzb1DVXz6T0NB+k5DJNJDICX0FszmmFmna6286wjBVuohJzul/ASaB/DbqjPrwW/Xw mhHRZ4giN6+u/idKRvLIo2GVxqBpEMFdvgR9aPy/nr8/gC3/Gj5+jvmTgiv/XE9tmUJf RAaP0HSIpZn2cXmQT4mqP9AhNqZ1nV8p7jE0bgh/udUYDTMnPuGzX/t05oPW2Wvod+p2 jt0VhXXNMaac/0M16LJzg2PWMPiCL9Y42nI93uUwDV9KWdNSJ2/o+tmtg+aiWST0QbhQ 3p0g== X-Gm-Message-State: AJIora/ctCHoe/x6GVO3c0FBtJpr4ureKKhRm8Id2/kv6rFZtgwTe2l7 JEGIJydmOMjkjyfwxc7MDA3W7JZ12AOVDQ== X-Google-Smtp-Source: AGRyM1suTLQ90NaePqkJonODPhZn+qB1qtie39i9Dt6DMiDSNFvMPeoRLTVMcuvZuziEUsOHpwy3bg== X-Received: by 2002:a05:600c:1e07:b0:39c:37a2:956b with SMTP id ay7-20020a05600c1e0700b0039c37a2956bmr7111533wmb.71.1655418797468; Thu, 16 Jun 2022 15:33:17 -0700 (PDT) Received: from pwmachine.home (17.pool80-103-97.dynamic.orange.es. [80.103.97.17]) by smtp.gmail.com with ESMTPSA id n4-20020a05600c4f8400b003971fc23185sm7912044wmq.20.2022.06.16.15.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 15:33:17 -0700 (PDT) From: Francis Laniel To: u-boot@lists.denx.de Cc: Marek Behun , Michael Nazzareno Trimarchi , Simon Glass , Wolfgang Denk , Harald Seiler , Tom Rini , Francis Laniel Subject: [RFC PATCH v4 20/28] cli: hush_2021: Enable if keyword Date: Fri, 17 Jun 2022 00:31:50 +0200 Message-Id: <20220616223158.9225-21-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220616223158.9225-1-francis.laniel@amarulasolutions.com> References: <20220616223158.9225-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.39 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.5 at phobos.denx.de X-Virus-Status: Clean Adds support for "if then else" construct both for command line interface and through run_command(). Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- common/cli_hush_upstream.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c index 6ef6bb6bf4..baf4f9aada 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_upstream.c @@ -3963,7 +3963,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 @@ -3993,7 +3992,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[] = { "{}", "()", @@ -4011,10 +4009,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; @@ -9829,6 +9825,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: @@ -9837,10 +9834,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; @@ -10359,12 +10357,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