Consolidate timeout generation code a bit.
authorColin Watson <cjwatson@ubuntu.com>
Fri, 29 Nov 2013 16:11:53 +0000 (16:11 +0000)
committerColin Watson <cjwatson@ubuntu.com>
Fri, 29 Nov 2013 16:11:53 +0000 (16:11 +0000)
util/grub.d/00_header.in

index 84d0499..d2e7252 100644 (file)
@@ -282,46 +282,41 @@ fi
 
 make_timeout ()
 {
-    if [ "x${3}" != "x" ] ; then
-       cat << EOF
-if [ x\$feature_timeout_style = xy ] ; then
-  set timeout_style=${3}
-  set timeout=${2}
-EOF
-       if [ "x${3}" != "xmenu" ] ; then
-           # Fallback hidden-timeout code in case the timeout_style feature
-           # is unavailable.  Note that we now ignore GRUB_HIDDEN_TIMEOUT
-           # and take the hidden-timeout from GRUB_TIMEOUT instead.
-           if [ "x${3}" = "xhidden" ] ; then
-               verbose=
+    if [ "x${1}${3}" != "x" ] ; then
+       if [ "x${3}" != "x" ] ; then
+           timeout="${2}"
+           style="${3}"
+       else
+           # Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
+           timeout="${1}"
+           if [ "x${2}" != "x0" ] ; then
+               grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
+           fi
+           if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
+               style="hidden"
            else
-               verbose=" --verbose"
+               style="countdown"
            fi
-           cat << EOF
-elif sleep$verbose --interruptible ${2} ; then
-  set timeout=0
-EOF
        fi
-       cat << EOF
-fi
-EOF
-    elif [ "x${1}" != "x" ] ; then
-       if [ "x${2}" != "x0" ] ; then
-           grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
-       fi
-       if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
-           verbose=
-           style="hidden"
-       else
+       if [ "x${style}" = "xcountdown" ] ; then
            verbose=" --verbose"
-           style="countdown"
+       else
+           verbose=
        fi
        cat << EOF
 if [ x\$feature_timeout_style = xy ] ; then
-  set timeout_style=$style
-  set timeout=${1}
-elif sleep$verbose --interruptible ${1} ; then
+  set timeout_style=${style}
+  set timeout=${timeout}
+EOF
+       if [ "x${style}" != "xmenu" ] ; then
+           cat << EOF
+# Fallback hidden-timeout code in case the timeout_style feature is
+# unavailable.
+elif sleep${verbose} --interruptible ${timeout} ; then
   set timeout=0
+EOF
+       fi
+       cat << EOF
 fi
 EOF
     else