Patchwork [U-Boot] Fix the behaviour of the 'run' command

login
register
mail settings
Submitter Timo Ketola
Date April 23, 2012, 9:57 a.m.
Message ID <1335175047-30984-1-git-send-email-timo@exertus.fi>
Download mbox | patch
Permalink /patch/154382/
State Accepted
Commit 030fca5228a2a1e946ac13ff8fae9ccb8c516d7b
Headers show

Comments

Timo Ketola - April 23, 2012, 9:57 a.m.
If one command fails, 'run' command should terminate and not execute
any remaining variables.

Signed-off-by: Timo Ketola <timo@exertus.fi>
---

This is based on u-boot-imx.git next. I hope that doesn't cause too
much trouble.

 common/main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Wolfgang Denk - April 23, 2012, 10:15 a.m.
Dear "Timo Ketola",

In message <1335175047-30984-1-git-send-email-timo@exertus.fi> you wrote:
> If one command fails, 'run' command should terminate and not execute
> any remaining variables.
> 
> Signed-off-by: Timo Ketola <timo@exertus.fi>
> ---
> 
> This is based on u-boot-imx.git next. I hope that doesn't cause too
> much trouble.
> 
>  common/main.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)

Tested on TQM5200S.

Tested-by: Wolfgang Denk <wd@denx.de>


Best regards,

Wolfgang Denk
Simon Glass - April 23, 2012, 7:56 p.m.
Hi Timo,

On Mon, Apr 23, 2012 at 9:57 PM, Timo Ketola <timo@exertus.fi> wrote:
> If one command fails, 'run' command should terminate and not execute
> any remaining variables.
>
> Signed-off-by: Timo Ketola <timo@exertus.fi>

Tested on sandbox after a bit of investigation.

Tested-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

This is a clear bug, since cmd_process() returns 1 on failure, but we
need builtin_run_command() to return -1. I suspect this might be the
problem that Wolfgang found some months ago, although perhaps in a
more subtle form.

We really need some tests for this sort of thing - I did create a few
for the new run_command_list(), but will make time to add some tests
for standard run_command() also.

Thanks for finding and fixing this.

Regards,
Simon

> ---
>
> This is based on u-boot-imx.git next. I hope that doesn't cause too
> much trouble.
>
>  common/main.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/common/main.c b/common/main.c
> index db181d3..3b9e39a 100644
> --- a/common/main.c
> +++ b/common/main.c
> @@ -1338,7 +1338,8 @@ static int builtin_run_command(const char *cmd, int flag)
>                        continue;
>                }
>
> -               rc = cmd_process(flag, argc, argv, &repeatable);
> +               if (cmd_process(flag, argc, argv, &repeatable))
> +                       rc = -1;
>
>                /* Did the user stop this? */
>                if (had_ctrlc ())
> --
> 1.7.5.4
>
Wolfgang Denk - April 23, 2012, 8:07 p.m.
Dear "Timo Ketola",

In message <1335175047-30984-1-git-send-email-timo@exertus.fi> you wrote:
> If one command fails, 'run' command should terminate and not execute
> any remaining variables.
> 
> Signed-off-by: Timo Ketola <timo@exertus.fi>
> ---
> 
> This is based on u-boot-imx.git next. I hope that doesn't cause too
> much trouble.
> 
>  common/main.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Patch

diff --git a/common/main.c b/common/main.c
index db181d3..3b9e39a 100644
--- a/common/main.c
+++ b/common/main.c
@@ -1338,7 +1338,8 @@  static int builtin_run_command(const char *cmd, int flag)
 			continue;
 		}
 
-		rc = cmd_process(flag, argc, argv, &repeatable);
+		if (cmd_process(flag, argc, argv, &repeatable))
+			rc = -1;
 
 		/* Did the user stop this? */
 		if (had_ctrlc ())