mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
fix(updater): fix input check on non-interactive runs
Reference: https://www.zsh.org/mla/users/2022/msg00067.html
This commit is contained in:
parent
dbd92a62ce
commit
69e2937891
1 changed files with 9 additions and 1 deletions
|
@ -95,13 +95,21 @@ function has_typed_input() {
|
|||
emulate -L zsh
|
||||
zmodload zsh/zselect
|
||||
|
||||
# Back up stty settings prior to disabling canonical mode
|
||||
# Consider that no input can be typed if stty fails
|
||||
# (this might happen if stdin is not a terminal)
|
||||
local termios
|
||||
termios=$(stty --save 2>/dev/null) || return 1
|
||||
{
|
||||
local termios=$(stty --save)
|
||||
# Disable canonical mode so that typed input counts
|
||||
# regardless of whether Enter was pressed
|
||||
stty -icanon
|
||||
|
||||
# Poll stdin (fd 0) for data ready to be read
|
||||
zselect -t 0 -r 0
|
||||
return $?
|
||||
} always {
|
||||
# Restore stty settings
|
||||
stty $termios
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue