All of lore.kernel.org
 help / color / mirror / Atom feed
* Commands not executed in the else branch
@ 2009-04-27  4:52 Pavel Roskin
  2009-04-27  6:15 ` Bean
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Roskin @ 2009-04-27  4:52 UTC (permalink / raw)
  To: grub-devel

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Commands not executed in the else branch
  2009-04-27  4:52 Commands not executed in the else branch Pavel Roskin
@ 2009-04-27  6:15 ` Bean
  2009-04-27 14:10   ` Pavel Roskin
  0 siblings, 1 reply; 4+ messages in thread
From: Bean @ 2009-04-27  6:15 UTC (permalink / raw)
  To: The development of GRUB 2

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 <proski@gnu.org> 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
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Bean



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Commands not executed in the else branch
  2009-04-27  6:15 ` Bean
@ 2009-04-27 14:10   ` Pavel Roskin
  2009-05-03  6:49     ` Bean
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Roskin @ 2009-04-27 14:10 UTC (permalink / raw)
  To: grub-devel

Quoting Bean <bean123ch@gmail.com>:

> 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
>       `?'.  */

Thanks, it's working fine!

-- 
Regards,
Pavel Roskin



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Commands not executed in the else branch
  2009-04-27 14:10   ` Pavel Roskin
@ 2009-05-03  6:49     ` Bean
  0 siblings, 0 replies; 4+ messages in thread
From: Bean @ 2009-05-03  6:49 UTC (permalink / raw)
  To: The development of GRUB 2

Hi,

Committed.

On Mon, Apr 27, 2009 at 10:10 PM, Pavel Roskin <proski@gnu.org> wrote:
> Quoting Bean <bean123ch@gmail.com>:
>
>> 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
>>      `?'.  */
>
> Thanks, it's working fine!
>
> --
> Regards,
> Pavel Roskin
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Bean



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-05-03  6:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-27  4:52 Commands not executed in the else branch Pavel Roskin
2009-04-27  6:15 ` Bean
2009-04-27 14:10   ` Pavel Roskin
2009-05-03  6:49     ` Bean

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.