grub: look for any way to set default menu item

This prepares the ability to write and read
the default menu item from the grubenv file.
If grub.cfg contains a line like '^default=id',
then the read value is not used.
Setting the default menu item from the grubenv file
will be indented inside the 'if' optator and therefore
does not match the '^default' pattern.
This commit is contained in:
Evgeny Sinelnikov 2021-05-19 15:52:34 +04:00 committed by Dmitriy Terekhin
parent 8354c1bb70
commit aed27a30f8

View File

@ -36,7 +36,7 @@ if [ -n "$GLOBAL_GRUB_DEFAULT" ]; then
exit 1
fi
fi
if ! grep -i '^default' "$CFG"; then
if ! grep -i '^\s*\(set\s\+\)\?default=' "$CFG"; then
DEFAULT="$(grep -i '\-\-id ' "$CFG" | head -1 | rev| cut -f2 -d' ' |rev)"
if [ -n "$DEFAULT" ]; then
echo "default=$DEFAULT" >> "$CFG"