Skip to contentSkip to conversation

Fix bad test on GRUB_DISABLE_SUBMENU.

PATCH Superseded Javier Martinez Canillas 2 participants 4 messages Sep 17, 2019 – Sep 20, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix bad test on GRUB_DISABLE_SUBMENU.

From: Prarit Bhargava <[email protected]>

The file /etc/grub.d/10_linux does

if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then

when it should do

if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then

which results in submenus in /boot/grub2/grub.cfg when GRUB_DISABLE_SUBMENU="yes".

Resolves: rhbz#1063414

---

 util/grub.d/10_linux.in | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
util/grub.d/10_linux.in +5 -1
index 4532266be68..58defdbd83f 100644
@@ -261,7 +261,11 @@ while [ "x$list" != "x" ] ; do
     fi
   fi
 
-  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
+  if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then
+    GRUB_DISABLE_SUBMENU="true"
+  fi
+
+  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
     linux_entry "${OS}" "${version}" simple \
     "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
 
Signature · 1 line
2.21.0
#1 lore raw
Quoted 28 lines · Javier Martinez Canillas

From: Prarit Bhargava <[email protected]>

The file /etc/grub.d/10_linux does

if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then

when it should do

if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then

which results in submenus in /boot/grub2/grub.cfg when GRUB_DISABLE_SUBMENU="yes".

Resolves: rhbz#1063414

---

 util/grub.d/10_linux.in | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
util/grub.d/10_linux.in +0 -0
index 4532266be68..58defdbd83f 100644
@@ -261,7 +261,11 @@ while [ "x$list" != "x" ] ; do
     fi

util/grub.d/10_linux.in while [ "x$list" != "x" ] ; do · line 270

Quoted 10 lines
util/grub.d/10_linux.in +5 -1
   fi
 
-  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
+  if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then
+    GRUB_DISABLE_SUBMENU="true"
+  fi
+
+  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
     linux_entry "${OS}" "${version}" simple \
     "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"

Well, I understand the problem but I do not like the patch. Why do you introduce "yes" and do not use "true"? Except GRUB_BUTTON_CMOS_ADDRESS, which is wrong IMO, all variables accept only true/false. So, if you want to add "yes" then do that for all. Otherwise you make only confusion. And there are more files which has the same issue, e.g. util/grub.d/10_hurd.in

Daniel

#2 lore raw

Hello Daniel,

Quoted 31 lines · Daniel Kiper
Quoted 30 lines · Javier Martinez Canillas

From: Prarit Bhargava <[email protected]>

The file /etc/grub.d/10_linux does

if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then

when it should do

if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then

which results in submenus in /boot/grub2/grub.cfg when GRUB_DISABLE_SUBMENU="yes".

Resolves: rhbz#1063414

---

 util/grub.d/10_linux.in | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
util/grub.d/10_linux.in +0 -0
index 4532266be68..58defdbd83f 100644
@@ -261,7 +261,11 @@ while [ "x$list" != "x" ] ; do
     fi
   fi
 
Quoted 13 lines

util/grub.d/10_linux.in while [ "x$list" != "x" ] ; do · line 270

Quoted 8 lines
util/grub.d/10_linux.in +5 -1
-  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
+  if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then
+    GRUB_DISABLE_SUBMENU="true"
+  fi
+
+  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
     linux_entry "${OS}" "${version}" simple \
     "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"

Well, I understand the problem but I do not like the patch. Why do you introduce "yes" and do not use "true"? Except GRUB_BUTTON_CMOS_ADDRESS, which is wrong IMO, all variables accept only true/false. So, if you want to add "yes" then do that for all. Otherwise you make only confusion.

Right, the problem is that as you said GRUB_DISABLE_SUBMENU is inconsistent with all the other options.

But since most variables use "true", someone who's reading the docs might wrongly assume that by "y" it really meant "yes" (since for all others a word is used and not a letter). That's what happened in the bug reported.

So this patch makes the option to support all of "y", "yes" and "true" to make sure that even if a user gets confused by the documentation, will be able to set it.

I don't think that will cause confusion if we fix the doc to mention that GRUB_DISABLE_SUBMENU has to be set to "true" like all the other options and add a comment in 10_linux.in explaining why it checks for the three values.

At the very least we need to keep supporting "y" besides "true" to avoid regressions for users that set to what the documentation used to mention.

Quoted 2 lines

And there are more files which has the same issue, e.g. util/grub.d/10_hurd.in

You are right, I'll change this in util/grub.d/10_hurd.in as well.

Quoted 2 lines

Daniel

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat
#3 lore raw
Quoted 55 lines · Javier Martinez Canillas

Hello Daniel,

Quoted 31 lines · Daniel Kiper
Quoted 30 lines · Javier Martinez Canillas

From: Prarit Bhargava <[email protected]>

The file /etc/grub.d/10_linux does

if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then

when it should do

if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then

which results in submenus in /boot/grub2/grub.cfg when GRUB_DISABLE_SUBMENU="yes".

Resolves: rhbz#1063414

---

 util/grub.d/10_linux.in | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
util/grub.d/10_linux.in +0 -0
index 4532266be68..58defdbd83f 100644
@@ -261,7 +261,11 @@ while [ "x$list" != "x" ] ; do
     fi
   fi
 
Quoted 13 lines

util/grub.d/10_linux.in while [ "x$list" != "x" ] ; do · line 270

Quoted 8 lines
util/grub.d/10_linux.in +5 -1
-  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
+  if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then
+    GRUB_DISABLE_SUBMENU="true"
+  fi
+
+  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
     linux_entry "${OS}" "${version}" simple \
     "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"

Well, I understand the problem but I do not like the patch. Why do you introduce "yes" and do not use "true"? Except GRUB_BUTTON_CMOS_ADDRESS, which is wrong IMO, all variables accept only true/false. So, if you want to add "yes" then do that for all. Otherwise you make only confusion.

Right, the problem is that as you said GRUB_DISABLE_SUBMENU is inconsistent with all the other options.

But since most variables use "true", someone who's reading the docs might wrongly assume that by "y" it really meant "yes" (since for all others a word is used and not a letter). That's what happened in the bug reported.

Quoted 7 lines

So this patch makes the option to support all of "y", "yes" and "true" to make sure that even if a user gets confused by the documentation, will be able to set it.

I don't think that will cause confusion if we fix the doc to mention that GRUB_DISABLE_SUBMENU has to be set to "true" like all the other options and add a comment in 10_linux.in explaining why it checks for the three values.

Works for me...

Quoted 2 lines

At the very least we need to keep supporting "y" besides "true" to avoid regressions for users that set to what the documentation used to mention.

Yep.

Quoted 3 lines
Quoted 1 line

And there are more files which has the same issue, e.g. util/grub.d/10_hurd.in

You are right, I'll change this in util/grub.d/10_hurd.in as well.

Thanks!

Daniel