From 9b70860ecca300bae6a8997c66352c03c730953c Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 29 Nov 2013 16:11:53 +0000 Subject: [PATCH] Consolidate timeout generation code a bit. --- util/grub.d/00_header.in | 63 ++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 84d04999d..d2e725201 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -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= - else - verbose=" --verbose" - 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" + 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 + style="countdown" + fi + fi + 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