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 0ABF5C433F5 for ; Sun, 6 Feb 2022 18:41:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F8FD83BED; Sun, 6 Feb 2022 19:38:48 +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="B/F3ArZJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D882183BD7; Sun, 6 Feb 2022 19:38:45 +0100 (CET) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (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 9A75383C20 for ; Sun, 6 Feb 2022 19:37:54 +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-x433.google.com with SMTP id s10so18571175wra.5 for ; Sun, 06 Feb 2022 10:37:54 -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=lHJHLs66lT8hbip7AOl0yvKd8U/jq77Gy12AK0aOmMY=; b=B/F3ArZJIMcSW/w2/MPRTHBwlK2xWxz7yqCoCOINQysWlDFrwn3Yor2Ls8s1k1Sa1y Y1Jt5sbOahVIJhR++nxOEQOQ++6Nk6xMjH28K2yTP7SlcJafUHHN6o26znpLciFTCih7 S4QhXD8FR37gLQRbBrccX/RbRHyKuuJtBV3uw= 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=lHJHLs66lT8hbip7AOl0yvKd8U/jq77Gy12AK0aOmMY=; b=DLE7dmyXflP49The6uysx6ArNxyj8cX+nWqTag0gV4vzbPd3Mpms/KZiv1oMi+I1fB U6xSszUzuw9qvl/IMqDKOMDQOvGtghl+v7/YPH3sFzpQXbiFQERXx68QfmmkdOEqSov4 vAzGqc2Waz3RhA9QUMaRi5DL877gPeH0t/0s1EFB4mIjqRIr7/dh8l2J720gYn7fIBiJ Ue7LTO6yFNhJ2SIx8vQkY5DjUMAzvl/h/93m2ZWIQRGIUF/S8jUV5RVdI7QJ/KCENTU0 Qhs73QcaV7uWoSTLN3nk25cdkftkfRni0QnsAv9FwdATL3hAU/0hX6+9ekVZYPvUveY0 ACQg== X-Gm-Message-State: AOAM531b5Cv4iSWi/d4oVy6qLAtpS+W/Wlv+MOvY3brfR2yH4lz0AwxU kxo77XW4AloDe/5RRZUTkGKrlKTgMufepQ== X-Google-Smtp-Source: ABdhPJy2ZBpUI1mdY385d9HuyHfRkI59n1O58HbDVdCTUfUyV7KpkaVS3A0YnZSEjnH+JZse5EZPWA== X-Received: by 2002:a5d:48cb:: with SMTP id p11mr3882807wrs.229.1644172674223; Sun, 06 Feb 2022 10:37:54 -0800 (PST) Received: from pwmachine.home ([2a01:cb14:983:1f00:e5b3:218b:cb92:2549]) by smtp.gmail.com with ESMTPSA id ay29sm7095011wmb.38.2022.02.06.10.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 10:37:53 -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 v2 18/21] cli: hush_2021: Enable if keyword Date: Sun, 6 Feb 2022 19:37:14 +0100 Message-Id: <20220206183717.57446-19-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220206183717.57446-1-francis.laniel@amarulasolutions.com> References: <20220206183717.57446-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 d1f76d4df5..5c783494d1 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_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