[grubcfg] Fix mismatched quoting and escaping.

If we use .replace("'", "'\\''") for escaping, we also need to use
single quotes, not double quotes.

This was broken by the port from '%' to format, which also randomly
changed quoting characters for no good reason. Changing the outer ones
does not matter, but \" or ' within a string is not the same thing!
This commit is contained in:
Kevin Kofler 2016-10-16 18:44:22 +02:00 committed by Philip
parent cd76aa599f
commit 4a7c469f96

View File

@ -65,7 +65,7 @@ def modify_grub_default(partitions, root_mount_point, distributor):
if swap_uuid:
kernel_params.append("resume=UUID={!s}".format(swap_uuid))
distributor_line = "GRUB_DISTRIBUTOR=\"{!s}\"".format(distributor_replace)
distributor_line = "GRUB_DISTRIBUTOR='{!s}'".format(distributor_replace)
if not os.path.exists(default_dir):
os.mkdir(default_dir)
@ -123,7 +123,7 @@ def modify_grub_default(partitions, root_mount_point, distributor):
else:
escaped_value = str(value).replace("'", "'\\''")
lines.append("{!s}=\"{!s}\"".format(key, escaped_value))
lines.append("{!s}='{!s}'".format(key, escaped_value))
if not have_kernel_cmd:
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"{!s}\"".format(" ".join(kernel_params))