From 2c72f1e096fe895fb20af790fa7ae8367e2e9f0d Mon Sep 17 00:00:00 2001 From: Denis Ollier Date: Tue, 9 Feb 2016 09:01:45 +0100 Subject: [PATCH] Make yaourt input behaviour consistent with pacman --- src/lib/abs.sh.in | 4 ++-- src/lib/alpm_query.sh | 5 ++++- src/lib/io.sh | 7 +++++-- src/lib/pkgbuild.sh.in | 18 +++++++++++------- src/pacdiffviewer.sh.in | 3 +-- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/lib/abs.sh.in b/src/lib/abs.sh.in index 94d0f25..3886af4 100644 --- a/src/lib/abs.sh.in +++ b/src/lib/abs.sh.in @@ -258,8 +258,8 @@ display_update() { SP_ARG="" sync_packages "$YAOURTTMPDIR/sysuplist" return 2 ;; - N) return 1;; - *) break;; + Y) break;; + *) return 1;; esac done } diff --git a/src/lib/alpm_query.sh b/src/lib/alpm_query.sh index 882ff9b..4f81c1f 100644 --- a/src/lib/alpm_query.sh +++ b/src/lib/alpm_query.sh @@ -43,10 +43,13 @@ search_pkgs_which() { # searching for packages installed as dependecy from another packages, but not required anymore search_forgotten_orphans() { + local answer + AURSEARCH=0 search 0 1; ret=$? [[ ! $PKGSFOUND ]] && return $ret prompt "$(gettext 'Do you want to remove these packages (with -Rcs options) ? ') $(yes_no 2)" - useragrees "YN" "N" || su_pacman -Rcs "${PKGSFOUND[@]#*/}" + answer=$(userinput "YN" "N") + [[ $answer = "Y" ]] && su_pacman -Rcs "${PKGSFOUND[@]#*/}" } # vim: set ts=4 sw=4 noet: diff --git a/src/lib/io.sh b/src/lib/io.sh index 18d3fd3..733dd89 100644 --- a/src/lib/io.sh +++ b/src/lib/io.sh @@ -75,8 +75,11 @@ userinput() { answer=$default else read -en $NOENTER - [[ $REPLY ]] && answer=$(echo ${REPLY^^*} | tr "$(gettext $_key)" "$_key") || answer=$default - [[ "${_key/$answer/}" = "$_key" ]] && answer=$default + if [[ $REPLY ]]; then + answer=$(echo ${REPLY^^*} | tr "$(gettext $_key)" "$_key") + else + answer=$default + fi fi echo $answer [[ "$answer" = "$default" ]] diff --git a/src/lib/pkgbuild.sh.in b/src/lib/pkgbuild.sh.in index ec1fb44..8af2bb8 100644 --- a/src/lib/pkgbuild.sh.in +++ b/src/lib/pkgbuild.sh.in @@ -340,8 +340,8 @@ install_package() { fi echo ;; - N) failed=1; break;; - *) break;; + Y) break;; + *) failed=1; break;; esac done (( ! failed )) && @@ -374,11 +374,11 @@ custom_pkg() { # on success, call install_package # Usage: package_loop ($pkgname, $trust) # $pkgname: name of package -# $trust: 1: default answer for editing: Y (for abs) +# $trust: 1: default answer for editing: N (for abs) package_loop() { local pl_pkgname=$1 local trust=${2:-0} - local default_answer=1 + local answer default_answer=1 local ret=0 failed=0 declare -a PKGBUILD_DEPS PKGBUILD_DEPS_INSTALLED \ PKGBUILD_CONFLICTS PKGBUILD_VARS @@ -396,7 +396,8 @@ package_loop() { case "$ret" in 0|2) break ;; 1) prompt "$(_gettext 'Restart building %s ? ' "$pl_pkgname")$(yes_no 2)" - builduseragrees "YN" "N" && { failed=1; break; } + answer=$(builduserinput "YN" "N") + [[ $answer = "Y" ]] || { failed=1; break; } ;; *) return 99 ;; # should never execute esac @@ -455,8 +456,11 @@ get_pkgbuild() { local newdir=$(mktemp --dry-run --tmpdir="." "$pkgdir.XXX") prompt2 "$(_gettext '%s directory already exist. [R]eplace, [C]hange to %s, [S]kip ?' "$pkgdir" "$newdir")" local answer=$(userinput "RCS" "R") - [[ $answer = "S" ]] && continue - [[ $answer = "C" ]] && pkgdir=$newdir + case $answer in + R) :;; + C) pkgdir=$newdir;; + *) continue;; + esac fi mkdir -p "$pkgdir" cd "$pkgdir" || continue diff --git a/src/pacdiffviewer.sh.in b/src/pacdiffviewer.sh.in index 7932366..3e9384d 100755 --- a/src/pacdiffviewer.sh.in +++ b/src/pacdiffviewer.sh.in @@ -160,10 +160,9 @@ suppress() { prompt "$(gettext 'Do you want to delete these files ?') $(\ yes_no 2) $(gettext '(S: no confirm)')" local answer=$(userinput "YNS" "N") - [[ "$answer" = "N" ]] && return local _opt="" [[ "$answer" = "Y" ]] && _opt="-i" - rm $_opt "${pacfiles[@]}" + [[ "$answer" = "Y" ]] || [[ "$answer" = "S" ]] && rm $_opt "${pacfiles[@]}" } # Manage .pac* file