grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Commands not executed in the else branch


From: Bean
Subject: Re: Commands not executed in the else branch
Date: Mon, 27 Apr 2009 14:15:02 +0800

Hi,

It's caused by the propagation of grub_errno value. This patch should fix it.

diff --git a/normal/execute.c b/normal/execute.c
index 8bf6d17..aec4589 100644
--- a/normal/execute.c
+++ b/normal/execute.c
@@ -177,6 +177,7 @@ grub_script_execute_cmdif (struct grub_script_cmd *cmd)
      read from the env variable `?'.  */
   grub_script_execute_cmd (cmdif->exec_to_evaluate);
   result = grub_env_get ("?");
+  grub_errno = 0;

   /* Execute the `if' or the `else' part depending on the value of
      `?'.  */

On Mon, Apr 27, 2009 at 12:52 PM, Pavel Roskin <address@hidden> wrote:
> Hello!
>
> While testing the new "test" command, I have found that the "else"
> branch is not executed in some cases.  "echo" and "set" are executed,
> but other commands are not.  Even "hello" is not working.  The problem
> is not specific to the "test" command.  I can do it with "search" as
> well:
>
> grub> if search -f /; then echo 0; else hello; fi
> error: no such device
> grub> if search -f /; then echo 0; else echo Hello World; fi
> Hello World
> error: no such device
> grub> if search -f /; then echo 0; else echo 1; hello; echo 2; fi
> 1
> 2
> error: no such device
> grub>
>
> The problem disappears after there is a true condition in the "if" part.
>
> --
> Regards,
> Pavel Roskin
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Bean




reply via email to

[Prev in Thread] Current Thread [Next in Thread]