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 ()
{
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