From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: [PATCH] hush: Fix assignments being misinterpreted as commands
Date: Mon, 01 Mar 2021 00:40:14 +0100 [thread overview]
Message-ID: <914D3972-B8A7-45A8-AC3E-95519C56EEB7@gmx.de> (raw)
In-Reply-To: <20210228212951.1175231-1-seanga2@gmail.com>
Am 28. Februar 2021 22:29:51 MEZ schrieb Sean Anderson <seanga2@gmail.com>:
>If there were no variable substitutions in a command, then initial
>assignments would be misinterpreted as commands, instead of being
>skipped
>over. This is demonstrated by the following example:
>
> => foo=bar echo baz
The commit message does not explain why this patch is needed.
What shall be the value off foo after this line?
What will be the output of
foo=bar echo ${foo}
with and without yor patch?
Best regards
Heinrich
> Unknown command 'foo=bar' - try 'help'
>
>Signed-off-by: Sean Anderson <seanga2@gmail.com>
>---
>
> common/cli_hush.c | 2 +-
> test/cmd/test_echo.c | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/common/cli_hush.c b/common/cli_hush.c
>index b7f0f0ff41..1b9bef64b6 100644
>--- a/common/cli_hush.c
>+++ b/common/cli_hush.c
>@@ -1672,7 +1672,7 @@ static int run_pipe_real(struct pipe *pi)
> return -1;
> }
> /* Process the command */
>- return cmd_process(flag, child->argc, child->argv,
>+ return cmd_process(flag, child->argc - i, child->argv + i,
> &flag_repeat, NULL);
> #endif
> }
>diff --git a/test/cmd/test_echo.c b/test/cmd/test_echo.c
>index 4183cf75bb..13e1fb7c82 100644
>--- a/test/cmd/test_echo.c
>+++ b/test/cmd/test_echo.c
>@@ -33,6 +33,8 @@ static struct test_data echo_data[] = {
> */
> {"setenv jQx X; echo \"a)\" ${jQx} 'b)' '${jQx}' c) ${jQx}; setenv
>jQx",
> "a) X b) ${jQx} c) X"},
>+ /* Test shell variable assignments without substitutions */
>+ {"foo=bar echo baz", "baz"},
> /* Test handling of shell variables. */
> {"setenv jQx; for jQx in 1 2 3; do echo -n \"${jQx}, \"; done; echo;",
> "1, 2, 3, "},
next prev parent reply other threads:[~2021-02-28 23:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-28 21:29 [PATCH] hush: Fix assignments being misinterpreted as commands Sean Anderson
2021-02-28 23:40 ` Heinrich Schuchardt [this message]
2021-02-28 23:51 ` Sean Anderson
2021-03-01 14:17 ` Tom Rini
2021-03-01 18:26 ` Heinrich Schuchardt
2021-03-01 23:07 ` Sean Anderson
2021-03-02 13:20 ` Tom Rini
2021-03-02 13:24 ` Sean Anderson
2021-03-02 13:34 ` Tom Rini
2021-03-02 23:09 ` Sean Anderson
2021-03-03 9:45 ` Wolfgang Denk
2021-03-01 18:43 ` Tom Rini
2021-04-13 14:27 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=914D3972-B8A7-45A8-AC3E-95519C56EEB7@gmx.de \
--to=xypron.glpk@gmx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).