dbd92a62ce1fc25a6819ae6d0a29dc8b8ec9a7dd
- Author
- Marc Cornellà <hello@mcornella.com>
- Committer
- Marc Cornellà <hello@mcornella.com>
- Date
Message
fix(updater): do not swallow 1 character in check for user input
Co-authored-by: Philippe Troin <phil@fifi.org>
Diff
1diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
2index 4484df4fe5f509a053a9147a6cade7e927f01208..33f30c85a7965c1fcf043a335c303c15980d67e4 100644
3--- a/tools/check_for_upgrade.sh
4+++ b/tools/check_for_upgrade.sh
5@@ -89,6 +89,23 @@ function update_ohmyzsh() {
6 fi
7 }
8
9+function has_typed_input() {
10+ # Created by Philippe Troin <phil@fifi.org>
11+ # https://zsh.org/mla/users/2022/msg00062.html
12+ emulate -L zsh
13+ zmodload zsh/zselect
14+
15+ {
16+ local termios=$(stty --save)
17+ stty -icanon
18+
19+ zselect -t 0 -r 0
20+ return $?
21+ } always {
22+ stty $termios
23+ }
24+}
25+
26 () {
27 emulate -L zsh
28
29@@ -159,7 +176,7 @@ function update_ohmyzsh() {
30 fi
31
32 # If user has typed input, show reminder and exit
33- if read -t -k 1; then
34+ if has_typed_input; then
35 echo
36 echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
37 return 0