Consolidate timeout generation code a bit.

This commit is contained in:
Colin Watson 2013-11-29 16:11:53 +00:00
parent 095588ef34
commit 9b70860ecc

View file

@ -282,46 +282,41 @@ fi
make_timeout () make_timeout ()
{ {
if [ "x${3}" != "x" ] ; then if [ "x${1}${3}" != "x" ] ; then
cat << EOF if [ "x${3}" != "x" ] ; then
if [ x\$feature_timeout_style = xy ] ; then timeout="${2}"
set timeout_style=${3} 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"
else 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" verbose=" --verbose"
style="countdown" else
verbose=
fi fi
cat << EOF cat << EOF
if [ x\$feature_timeout_style = xy ] ; then if [ x\$feature_timeout_style = xy ] ; then
set timeout_style=$style set timeout_style=${style}
set timeout=${1} set timeout=${timeout}
elif sleep$verbose --interruptible ${1} ; then 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 set timeout=0
EOF
fi
cat << EOF
fi fi
EOF EOF
else else