Comment 8 for bug 445952

Revision history for this message
Joe Philipps (2-launchpad-joe-philipps-us) wrote :

IMHO, this isn't a GRUB2 (grub-pc) bug, it is the documented behavior of the shell used to generate the configuration file (default grub.cfg). So-called here-documents (used extensively in the distributed default scripts) are documented to interpolate shell variables, consume quoting, etc. Perhaps what is not particularly clear is that the /etc/default/grub and /etc/grub.d/* files are sourced, therefore backslashes, quotes, and apostrophes within it must be used judiciously (because levels of quoting will be consumed).

In the example of the memmap case, $0, the name of the program, is being substituted. That's why using the apostrophe method of quoting works. Similarly, it has been a long standing voodoo of sorts to know how to escape with backslashes so that the proper number will be stripped off at the final evaluation, and get the character one is trying to escape (such as "). That's also why sometimes it's easier to use the apostrophe for quoting to include spaces, dollar, and double quotes. Consider it's also possible to use a hybrid quoting approach too, such as:

GRUB_CMDLINE_LINUX='nolapic memmap=64$0x24190000 console='"$GRUB_TERMINAL"' console=tty2'

(of course, that wouldn't quite work in reality, as the console device names for GRUB and Linux differ).