summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarc Cornellà <hello@mcornella.com>2022-02-11 10:01:48 +0100
committerMarc Cornellà <hello@mcornella.com>2022-02-11 10:04:51 +0100
commitdbd92a62ce1fc25a6819ae6d0a29dc8b8ec9a7dd (patch)
tree7a3ff36561a167890f162f759324fa6d86cf66f0 /tools
parent7b708519b9395914fb47b6c31132fb67fb8b721b (diff)
downloadzsh-dbd92a62ce1fc25a6819ae6d0a29dc8b8ec9a7dd.tar.gz
zsh-dbd92a62ce1fc25a6819ae6d0a29dc8b8ec9a7dd.tar.bz2
zsh-dbd92a62ce1fc25a6819ae6d0a29dc8b8ec9a7dd.zip
fix(updater): do not swallow 1 character in check for user input
Co-authored-by: Philippe Troin <phil@fifi.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/check_for_upgrade.sh19
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
index 4484df4fe..33f30c85a 100644
--- a/tools/check_for_upgrade.sh
+++ b/tools/check_for_upgrade.sh
@@ -89,6 +89,23 @@ function update_ohmyzsh() {
fi
}
+function has_typed_input() {
+ # Created by Philippe Troin <phil@fifi.org>
+ # https://zsh.org/mla/users/2022/msg00062.html
+ emulate -L zsh
+ zmodload zsh/zselect
+
+ {
+ local termios=$(stty --save)
+ stty -icanon
+
+ zselect -t 0 -r 0
+ return $?
+ } always {
+ stty $termios
+ }
+}
+
() {
emulate -L zsh
@@ -159,7 +176,7 @@ function update_ohmyzsh() {
fi
# If user has typed input, show reminder and exit
- if read -t -k 1; then
+ if has_typed_input; then
echo
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
return 0