Skip to content
This repository has been archived by the owner on Aug 9, 2019. It is now read-only.

[PATCH] Improve bad keypress handling #37

Closed
stevenhoneyman opened this issue Jun 16, 2014 · 1 comment · Fixed by #230
Closed

[PATCH] Improve bad keypress handling #37

stevenhoneyman opened this issue Jun 16, 2014 · 1 comment · Fixed by #230

Comments

@stevenhoneyman
Copy link
Contributor

Using pacman as an example, when you get asked a question that has a default answer; if you press Enter, it uses the default. If you press a random letter (e.g. accidently pressing M instead of N), it stops/exits, but Yaourt would instead just use the default. The patch below makes it behave like pacman - unhandled keys mean exit, but ENTER still uses default.

--- a/src/lib/abs.sh.in 2014-06-06 13:30:36.000000000 +0100
+++ b/src/lib/abs.sh.in 2014-06-16 20:52:11.705753729 +0100
@@ -188,8 +188,8 @@
               SP_ARG="" sync_packages "$YAOURTTMPDIR/sysuplist"
               return 2
               ;;
-           N) return 1;;
-           *) break;;
+           Y) break;;
+           *) return 1;;
        esac
    done
 }
--- a/src/lib/io.sh 2014-06-06 13:30:36.000000000 +0100
+++ b/src/lib/io.sh 2014-06-16 20:48:33.555750222 +0100
@@ -76,7 +76,9 @@
    else
        read -en $NOENTER
        [[ $REPLY ]] && answer=$(echo ${REPLY^^*} | tr "$(gettext $_key)" "$_key") || answer=$default
-       [[ "${_key/$answer/}" = "$_key" ]] && answer=$default
+       if [[ "${_key/$answer/}" = "$_key" ]]; then
+           [[ -z "$answer" ]] && answer=$default || answer="Q"
+       fi
    fi
    echo $answer
    [[ "$answer" = "$default" ]]
@larchunix
Copy link
Collaborator

This patch has unwanted side effects.

For instance:

$ yaourt -Qdt
extra/swig 3.0.8-1
==> Do you want to remove these packages (with -Rcs options) ?  [y/N]
==> -----------------------------------------------------------------
==>

After applying your patch, all answers except N trigger a removal.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants