diff options
Diffstat (limited to 'sys-fs/cryptsetup/files/dmcrypt.rc')
-rwxr-xr-x | sys-fs/cryptsetup/files/dmcrypt.rc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sys-fs/cryptsetup/files/dmcrypt.rc b/sys-fs/cryptsetup/files/dmcrypt.rc index 7be9a9a3fdf9..130036b9202f 100755 --- a/sys-fs/cryptsetup/files/dmcrypt.rc +++ b/sys-fs/cryptsetup/files/dmcrypt.rc @@ -1,7 +1,7 @@ #!/sbin/runscript # Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-fs/cryptsetup/files/dmcrypt.rc,v 1.3 2012/05/11 08:18:10 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-fs/cryptsetup/files/dmcrypt.rc,v 1.4 2012/05/11 08:33:01 vapier Exp $ depend() { before checkfs fsck @@ -71,17 +71,26 @@ dm_crypt_execute_dmcrypt() { if [ -n "${key}" ] ; then read_abort() { # some colors - local ans - shift + local ans savetty resettty [ -z "${NORMAL}" ] && eval $(eval_ecolors) einfon " $1? (${WARN}yes${NORMAL}/${GOOD}No${NORMAL}) " - if ! read -n 1 $* ans ; then + shift + # This is ugly as s**t. But POSIX doesn't provide `read -t`, so + # we end up having to implement our own crap with stty/etc... + savetty=$(stty -g) + resettty='stty ${savetty}; trap - EXIT HUP INT TERM' + trap 'eval "${resettty}"' EXIT HUP INT TERM + stty -icanon + [ "${1}" = -t ] && stty min 0 time "$(( $2 * 10 ))" + ans=$(dd count=1 bs=1 2>/dev/null) || ans='' + eval "${resettty}" + if [ -z "${ans}" ] ; then printf '\r' else echo fi case ${ans} in - [yY]|[yY][eE][sS]) return 0;; + [yY]) return 0;; *) return 1;; esac } |