summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-09-01 02:43:44 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-09-01 02:45:48 +0900
commit5b7457ff08668efef879174fc7f855fc77d6d18d (patch)
treecb03666137ef7ec3777b31c1bd777ecef3c2cbc0 /install
parent48adad5454c25a626b5f8398cce97701d63af640 (diff)
[install] Wait for a linefeed when asking for confirmation
Close #1035
Diffstat (limited to 'install')
-rwxr-xr-xinstall16
1 files changed, 8 insertions, 8 deletions
diff --git a/install b/install
index 4a41b6b9..f51479f2 100755
--- a/install
+++ b/install
@@ -59,14 +59,14 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
fzf_base="$(pwd)"
ask() {
- # If stdin is a tty, we are "interactive".
- # non-interactive shell: wait for a linefeed
- # interactive shell: continue after a single keypress
- read_n=$([ -t 0 ] && echo "-n 1")
-
- read -p "$1 ([y]/n) " $read_n -r
- echo
- [[ $REPLY =~ ^[Nn]$ ]]
+ while true; do
+ read -p "$1 ([y]/n) " -r
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
+ return 1
+ elif [[ $REPLY =~ ^[Nn]$ ]]; then
+ return 0
+ fi
+ done
}
check_binary() {