mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-17 07:43:39 -05:00
Merge pull request #188 from justinmk/non-interactive-shell
install: wait for LF in non-interactive shell
This commit is contained in:
9
install
9
install
@@ -5,8 +5,15 @@ version=0.9.7
|
|||||||
cd $(dirname $BASH_SOURCE)
|
cd $(dirname $BASH_SOURCE)
|
||||||
fzf_base=$(pwd)
|
fzf_base=$(pwd)
|
||||||
|
|
||||||
|
# If stdin is a tty, we are "interactive".
|
||||||
|
[ -t 0 ] && interactive=yes
|
||||||
|
|
||||||
ask() {
|
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
|
echo
|
||||||
[[ ! $REPLY =~ ^[Nn]$ ]]
|
[[ ! $REPLY =~ ^[Nn]$ ]]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user