mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-22 19:09:00 +00:00
install: wait for LF in non-interactive shell
"read -n 1 ..." ignores all but the first character of a line-delimited stream (e.g. "yes n | ./install").
This commit is contained in:
parent
3ec83babac
commit
d4daece76b
9
install
9
install
@ -5,8 +5,15 @@ version=0.9.7
|
||||
cd $(dirname $BASH_SOURCE)
|
||||
fzf_base=$(pwd)
|
||||
|
||||
# If stdin is a tty, we are "interactive".
|
||||
[ -t 0 ] && interactive=yes
|
||||
|
||||
ask() {
|
||||
read -p "$1 ([y]/n) " -n 1 -r
|
||||
# non-interactive shell: wait for a linefeed
|
||||
# interactive shell: continue after a single keypress
|
||||
[ -n "$interactive" ] && read_n='-n 1' || read_n=
|
||||
|
||||
read -p "$1 ([y]/n) " $read_n -r
|
||||
echo
|
||||
[[ ! $REPLY =~ ^[Nn]$ ]]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user