Commands not executed in the else branch
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.
Signature · 2 lines
Regards, Pavel Roskin
Hi,
It's caused by the propagation of grub_errno value. This patch should fix it.
normal/execute.c +1 -0
@@ -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 `?'. */
Quoted 31 lines · Pavel Roskin
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
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 1 line
Bean
Quoting Bean <[email protected]>:
Quoted 9 lines
Hi,
It's caused by the propagation of
grub_errnovalue. This patch should fix it.normal/execute.c +0
-0
normal/execute.c grub_script_execute_cmdif (struct grub_script_cmd *cmd) · line 183
Quoted 7 lines
normal/execute.c +1
-0@@ -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!
Signature · 2 lines
Regards, Pavel Roskin
Hi,
Committed.
Quoted 33 lines · Pavel Roskin
Quoting Bean <[email protected]>:
Quoted 16 lines
Hi,
It's caused by the propagation of
grub_errnovalue. This patch should fix it.normal/execute.c +0
-0@@ -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;Quoted 2 lines
/* Execute the
if' or theelse' part depending on the value of `?'. */Thanks, it's working fine!
--
Regards,
Pavel Roskin_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 1 line
Bean