diff options
author | Marc Cornellà <hello@mcornella.com> | 2022-02-11 19:51:52 +0100 |
---|---|---|
committer | Marc Cornellà <hello@mcornella.com> | 2022-02-11 19:51:52 +0100 |
commit | 69e29378915d53655d8fa8dc181b6cf526754569 (patch) | |
tree | 3b60e30d552c78f27588b98bcbc41b6e20545de5 /tools | |
parent | dbd92a62ce1fc25a6819ae6d0a29dc8b8ec9a7dd (diff) | |
download | zsh-69e29378915d53655d8fa8dc181b6cf526754569.tar.gz zsh-69e29378915d53655d8fa8dc181b6cf526754569.tar.bz2 zsh-69e29378915d53655d8fa8dc181b6cf526754569.zip |
fix(updater): fix input check on non-interactive runs
Reference: https://www.zsh.org/mla/users/2022/msg00067.html
Diffstat (limited to 'tools')
-rw-r--r-- | tools/check_for_upgrade.sh | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 33f30c85a..a36aecb84 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -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 } } |