Skip to content

Commit

Permalink
fix(updater): fix input check on non-interactive runs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcornella authored and kareefardi committed Feb 21, 2022
1 parent b7238ad commit fb5b805
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tools/check_for_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit fb5b805

Please sign in to comment.