Skip to content

Commit

Permalink
[install] Wait for a linefeed when asking for confirmation
Browse files Browse the repository at this point in the history
Close #1035
  • Loading branch information
junegunn committed Aug 31, 2017
1 parent 48adad5 commit 5b7457f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 5b7457f

Please sign in to comment.