Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the fallback mechanism when menu entries fail to boot #195

Open
wants to merge 2 commits into
base: fedora-42
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions grub-core/normal/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,14 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
if (ptr && ptr[0] && ptr[1])
grub_env_set ("default", ptr + 1);

grub_script_execute_new_scope (entry->sourcecode, entry->argc, entry->args);
err = grub_script_execute_new_scope (entry->sourcecode, entry->argc, entry->args);

if (errs_before != grub_err_printed_errors)
grub_wait_after_message ();

errs_before = grub_err_printed_errors;

if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
if (err == GRUB_ERR_NONE && grub_loader_is_loaded ())
/* Implicit execution of boot, only if something is loaded. */
err = grub_command_execute ("boot", 0, 0);

Expand Down
5 changes: 4 additions & 1 deletion grub-core/script/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,10 @@ grub_script_execute_sourcecode (const char *source)
break;
}

ret = grub_script_execute (parsed_script);
/* Don't let trailing blank lines determine the return code. */
if (parsed_script->cmd)
ret = grub_script_execute (parsed_script);

grub_script_free (parsed_script);
grub_free (line);
}
Expand Down
10 changes: 9 additions & 1 deletion tests/grub_script_eval.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
eval echo "Hello world"
valname=tst
eval $valname=hi
echo $tst
echo $tst

if eval "
false
"; then
echo should have failed
else
echo failed as expected
fi