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 4CCABC433F5 for ; Sun, 6 Feb 2022 18:40:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F187283BCC; Sun, 6 Feb 2022 19:38:32 +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="SDbu+I3X"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0AB1883C04; Sun, 6 Feb 2022 19:38:31 +0100 (CET) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 4AE3983C0A for ; Sun, 6 Feb 2022 19:37:50 +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-wm1-x32b.google.com with SMTP id o1-20020a1c4d01000000b0034d95625e1fso13005408wmh.4 for ; Sun, 06 Feb 2022 10:37:50 -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=IF3CF1JxKlc6ToXp+fGJhkYiHsAE1ncrGcURf1Maamk=; b=SDbu+I3XSBv7RW/5/hhvFMfOsF8di7gC4bszT+odB82sro8i4iotw/YVNIh1QKV98R lRXYdTwwNWBI9sqtJE8Er+cwclOtSuW1adqtkyL7lD1rc8aMELs7jEH4mmgH7NZCkMh2 3d/h8a61ZJxNirmcAc630TWI+27GmugZhv81g= 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=IF3CF1JxKlc6ToXp+fGJhkYiHsAE1ncrGcURf1Maamk=; b=sVQU0tEtYKrzsHmOoJt1KQXw2tR/iHC/clWiomY5yowxw/cypInoCKTPi2H3bBIOxd dEzdaA/y6BBC5/EjUPt0hXrlKcUKmI90b8H3o19sIGI1hYm+z/JKwXklk9fX7Awb4APr po9Da4hltcoY0QbZVnEEavF531ggADwkpsAB7azqTorLBzRAD3/XovIVgUMyetATvs8g gQU+c8r2brnNurZERwMKlLKU8hmVXFwEvpPKJDsHYQBu7Q9ELZtSJR8GnuQLk+TV8V1j mYMcT74/cU+sz4wLS2BQg97QFdbCz81x9VN/lTBESThxT1uwXIIYn/O4MWOZ4vwjq/t+ NdEg== X-Gm-Message-State: AOAM531qdBmSSaOuxJ5D9t1CaP5W0qtzrrSTI8fygTnoj9uonIOxVgyJ PGgmZ1Y6d4toSqIYfDkw/xNgTb45hPVscQ== X-Google-Smtp-Source: ABdhPJyo8gFeDKXBaz/5uJijjgYh5VhveAfj0GCqITrUrRI+ap1ula02YvW/rQgaqWUmei3owuo46Q== X-Received: by 2002:a1c:4645:: with SMTP id t66mr10857338wma.39.1644172669918; Sun, 06 Feb 2022 10:37:49 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 10:37:49 -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 14/21] cli: Modify run_command() to add hush 2021 as parser Date: Sun, 6 Feb 2022 19:37:10 +0100 Message-Id: <20220206183717.57446-15-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 Enables using, in code, run_command() while using hush 2021 as parser. It also enables the command run to be used by CLI user of hush 2021. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- common/cli.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/common/cli.c b/common/cli.c index 090677f7a0..46afa34b98 100644 --- a/common/cli.c +++ b/common/cli.c @@ -47,8 +47,21 @@ int run_command(const char *cmd, int flag) hush_flags |= FLAG_CONT_ON_NEWLINE; return parse_string_outer(cmd, hush_flags); #else /* HUSH_2021_PARSER */ - /* Not yet implemented. */ - return 0; + /* + * Possible values for flags are the following: + * FLAG_EXIT_FROM_LOOP: This flags ensures we exit from loop in + * parse_and_run_stream() after first iteration while normal behavior, + * i.e. when called from cli_loop(), is to loop infinitely. + * FLAG_PARSE_SEMICOLON: Hush 2021 parses ';' and does not stop first + * time it sees one. So, I think we do not need this flag. + * FLAG_REPARSING: For the moment, I do not understand the goal of this + * flag. + * FLAG_CONT_ON_NEWLINE: This flag seems to be used to continue parsing + * even when reading '\n' when coming from run_command(). In this case, + * Hush 2021 reads until it finds '\0'. So, I think we do not need this + * flag. + */ + return parse_string_outer(cmd, FLAG_EXIT_FROM_LOOP); #endif } -- 2.25.1