[prev in list] [next in list] [prev in thread] [next in thread]
List: grub-bug
Subject: grub-reboot is hard to use
From: hackerb9 () member ! fsf ! org
Date: 2019-09-12 12:29:15
Message-ID: CAO+cPoM1Zd2=JqByPHqWRz1h8cWD-CXMtq4MjruZajEU9GhfRw () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
The grub-reboot command is very handy, but has a fatal flaw on config files
with submenus. It requires the user to parse grub.cfg to figure out
non-obvious MENU_ENTRY numbers separated by greater than signs. It would be
nice if it showed a list and asked the user which boot entry is desired.
I've included below a patched version of grub-reboot which does exactly
that. It is imperfect, but I believe it shows what could be done without
too much more work. The main flaw is a lack of a decent parser for the
config file (an awk kludge is included instead). A secondary flaw is that
it uses Bash's mapfile and select commands. For maximum portability, it may
make sense to try to reimplement these as Bourne shell.
—b9
$ *grub-reboot -h*
Usage: grub-reboot [OPTION] [MENU_ENTRY]
Set the default boot menu entry for GRUB, for the next boot only.
-h, --help print this message and exit
-V, --version print the version information and exit
-s, --select interactively select entry to boot (DEFAULT)
--boot-directory=DIR expect GRUB images under the directory DIR/grub
instead of the /boot/grub directory
MENU_ENTRY is a number, a menu item title or a menu item identifier.
Please note that menu items in submenus or sub-submenus require
specifying the submenu components and then the menu item component.
The titles should be separated using the greater-than character (>)
with no extra spaces. Depending on your shell some characters
including > may need escaping. More information about this is available
in the GRUB Manual in the section about the 'default' command.
Report bugs to <bug-grub@gnu.org>.
$ *grub-reboot*
Please pick an OS to reboot into (for this next boot only). ^C to cancel.
1) 0>0 Debian GNU/Linux
2) 1 submenu 'Advanced options for Debian GNU/Linux'
3) 1>0 Debian GNU/Linux, with Linux 4.19.0-6-amd64
4) 1>1 Debian GNU/Linux, with Linux 4.19.0-6-amd64 (recovery
mode)
5) 1>2 Debian GNU/Linux, with Linux 4.9.0-11-amd64
6) 1>3 Debian GNU/Linux, with Linux 4.9.0-11-amd64 (recovery
mode)
7) 1>4 Debian GNU/Linux, with Linux 4.9.0-3-amd64
8) 1>5 Debian GNU/Linux, with Linux 4.9.0-3-amd64 (recovery mode)
9) None of the above.
#?* 4.9*
Next reboot will be into `Debian GNU/Linux, with Linux 4.9.0-11-amd64'
[Attachment #5 (text/html)]
<div dir="ltr"><div>The grub-reboot command is very handy, but has a fatal flaw on \
config files with submenus. It requires the user to parse grub.cfg to figure out \
non-obvious MENU_ENTRY numbers separated by greater than signs. It would be nice if \
it showed a list and asked the user which boot entry is desired. \
<br></div><div><br></div><div>I've included below a patched version of \
grub-reboot which does exactly that. It is imperfect, but I believe it shows what \
could be done without too much more work. The main flaw is a lack of a decent parser \
for the config file (an awk kludge is included instead). A secondary flaw is that it \
uses Bash's mapfile and select commands. For maximum portability, it may make \
sense to try to reimplement these as Bourne \
shell.<br></div><div><br></div><div>—b9</div><div \
style="margin-left:40px"><br></div><div><div style="margin-left:40px"><span \
style="font-family:monospace">$ <b>grub-reboot -h</b><br>Usage: grub-reboot [OPTION] \
[MENU_ENTRY]<br>Set the default boot menu entry for GRUB, for the next boot only.<br> \
-h, --help print this message and exit<br> -V, --version \
print the version information and exit<br> -s, --select \
interactively select entry to boot (DEFAULT)<br> --boot-directory=DIR expect \
GRUB images under the directory DIR/grub<br> \
instead of the /boot/grub directory<br><br>MENU_ENTRY is a number, a menu item title \
or a menu item identifier. <br>Please note that menu items in submenus or \
sub-submenus require<br>specifying the submenu components and then the menu item \
component. <br>The titles should be separated using the greater-than character \
(>)<br>with no extra spaces. Depending on your shell some characters<br>including \
> may need escaping. More information about this is available<br>in the GRUB \
Manual in the section about the 'default' command. <br><br>Report bugs to \
<<a href="mailto:bug-grub@gnu.org">bug-grub@gnu.org</a>>.</span></div><div \
style="margin-left:40px"><span style="font-family:monospace">$ \
<b>grub-reboot</b><br>Please pick an OS to reboot into (for this next boot only). \
^C to cancel.<br>1) 0>0 Debian GNU/Linux <br>2) 1 submenu 'Advanced \
options for Debian GNU/Linux' <br>3) 1>0 Debian GNU/Linux, \
with Linux 4.19.0-6-amd64 <br>4) 1>1 Debian GNU/Linux, with Linux \
4.19.0-6-amd64 (recovery mode) <br>5) 1>2 Debian GNU/Linux, with \
Linux 4.9.0-11-amd64 <br>6) 1>3 Debian GNU/Linux, with Linux \
4.9.0-11-amd64 (recovery mode) <br>7) 1>4 Debian GNU/Linux, with \
Linux 4.9.0-3-amd64 <br>8) 1>5 Debian GNU/Linux, with Linux \
4.9.0-3-amd64 (recovery mode) <br>9) None of the above.<br>#?<b> 4.9</b><br>Next \
reboot will be into `Debian GNU/Linux, with Linux \
4.9.0-11-amd64'<br></span></div><br></div></div>
["grub-reboot" (application/octet-stream)]
[Attachment #7 (text/plain)]
_______________________________________________
Bug-grub mailing list
Bug-grub@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-grub
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic