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 6FEFEC433F5 for ; Fri, 31 Dec 2021 16:16:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E49E483774; Fri, 31 Dec 2021 17:15: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=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="LEIGyv3K"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C2FF183774; Fri, 31 Dec 2021 17:14:53 +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 D1C308348F for ; Fri, 31 Dec 2021 17:14:12 +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 v11so56719960wrw.10 for ; Fri, 31 Dec 2021 08:14:12 -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=g27uq89WnUD84qUirzrIgHZV6u8Oo4mHzJ3NCmq9rqU=; b=LEIGyv3KxqKumD/cuDbTpttLu/4iwQ02UVqCUFKaTO7Tk3jnelRCJSyNRcKPBuaRUE N3z1fJOi4pi+Jbq/4Z3xInb4gjAsMZlQ2LdjkRv3auEPp9+g1N5EGnHS8/qSR34sz00y MkTG4/gFPYFOZvFFmQEAIT8Ke2Bc72FR0jsKI= 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=g27uq89WnUD84qUirzrIgHZV6u8Oo4mHzJ3NCmq9rqU=; b=B1W7h4q8shi8N++xT2M0uNKWVH8NdDDfsjCFAZK9WnKmOtbcLIGNIEr1k9iXosrKhB fYMrb6dZSrDz+ljj2BYw3lJvIKNBa6E2a7RBmBwSvkmz0MCvGZI7g/1JAyKwFLnD3/X3 tpxekWNospMQCWstwE6efuxaDWfKEKOt5U8uKPrzE4N5u4JuOGonDF/dkHPQ+gRRZX6Z 89sSStiv5+NvpgD0xK3QPEPSKwLV9hUteo2PKI+8iX2q5Dq8mpYrHJrZEjx+zBTxIZJ6 mKeoZvhj2FCrtHdOLWc18yfI31rYSHkxaR68VfbvRa7mraQ2yUM/+mM72C28Lhd6Km91 KoJg== X-Gm-Message-State: AOAM533kNx+dvd863MBH7oYEkcyr2/lt+mgs82fnVEsHHEQ5lerQFYsw Bk6ZXEgwbe9NojI81KqC3AhuJ/iQs1yI+A== X-Google-Smtp-Source: ABdhPJxLWgxvnn8wlSxa3eiw7rqh+V37z4C3rNLF6V7CvZqIQu1CkA4wX1mHKXXTkjOJR+VUm/ZF3A== X-Received: by 2002:a05:6000:1085:: with SMTP id y5mr30552593wrw.696.1640967252502; Fri, 31 Dec 2021 08:14:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 08:14:12 -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 14/21] cli: Modify run_command() to add hush 2021 as parser. Date: Fri, 31 Dec 2021 17:13:20 +0100 Message-Id: <20211231161327.24918-15-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 then 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 --- 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