846f417eb8ec76e8eee70000e289b8b81f19d480

Author
Marc Cornellà <hello@mcornella.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(updater): check for typed input before automatically updating (#10830)

Diff

 1diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
 2index d3ad7582cff10144c14a8b934d3c70d7016a726e..149500aa9ef65de0131b482965c5f8cb1b3ebed1 100644
 3--- a/tools/check_for_upgrade.sh
 4+++ b/tools/check_for_upgrade.sh
 5@@ -180,23 +180,17 @@ function has_typed_input() {
 6     return
 7   fi
 8 
 9-  # Don't ask for confirmation before updating if in auto mode
10-  if [[ "$update_mode" = auto ]]; then
11-    update_ohmyzsh
12-    return $?
13-  fi
14-
15-  # If in reminder mode show reminder and exit
16-  if [[ "$update_mode" = reminder ]]; then
17+  # If in reminder mode or user has typed input, show reminder and exit
18+  if [[ "$update_mode" = reminder ]] || has_typed_input; then
19+    printf '\r\e[0K' # move cursor to first column and clear whole line
20     echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
21     return 0
22   fi
23 
24-  # If user has typed input, show reminder and exit
25-  if has_typed_input; then
26-    echo
27-    echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
28-    return 0
29+  # Don't ask for confirmation before updating if in auto mode
30+  if [[ "$update_mode" = auto ]]; then
31+    update_ohmyzsh
32+    return $?
33   fi
34 
35   # Ask for confirmation and only update on 'y', 'Y' or Enter