The grub_script_execute_sourcecode() parses and executes code one line at a time, updating the return code each time because only the last line determines the final status. However, trailing new lines were also executed, masking any failure on the previous line. Fix this by only trying to execute the command when there is actually one present. This has presumably never been noticed because this code is not used by regular functions, only in special cases like eval and menu entries. The latter generally don't return at all, having booted an OS. When failing to boot, upstream GRUB triggers the fallback mechanism regardless of the return code. We noticed the problem while using Red Hat's patches, which change this behaviour to take account of the return code. In that case, a failure takes you back to the menu rather than triggering a fallback. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
15 lines
181 B
Plaintext
15 lines
181 B
Plaintext
#! @builddir@/grub-shell-tester
|
|
|
|
eval echo "Hello world"
|
|
valname=tst
|
|
eval $valname=hi
|
|
echo $tst
|
|
|
|
if eval "
|
|
false
|
|
"; then
|
|
echo should have failed
|
|
else
|
|
echo failed as expected
|
|
fi
|