36f444ed7325720ec05f182781ec7d6c9a4d675c

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

Message

fix(update): fix error exit code on update check (#10033)

This patch removes the 'exit 1' status code when the update check
finishes or is ended with CTRL+C.

Fixes #10033

Diff

 1diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
 2index 29a48b88033641c98aaf1378663b453a6610f27c..e87da3487634c3cc6f32ce83405e49d5b22875c7 100644
 3--- a/tools/check_for_upgrade.sh
 4+++ b/tools/check_for_upgrade.sh
 5@@ -48,14 +48,17 @@ function update_ohmyzsh() {
 6     return
 7   fi
 8 
 9-  # Remove lock directory on exit. `return 1` is important for when trapping a SIGINT:
10+  # Remove lock directory on exit. `return $ret` is important for when trapping a SIGINT:
11   #  The return status from the function is handled specially. If it is zero, the signal is
12   #  assumed to have been handled, and execution continues normally. Otherwise, the shell
13   #  will behave as interrupted except that the return status of the trap is retained.
14+  #  This means that for a CTRL+C, the trap needs to return the same exit status so that
15+  #  the shell actually exits what it's running.
16   trap "
17-  unset -f current_epoch update_last_updated_file update_ohmyzsh
18-  command rm -rf '$ZSH/log/update.lock'
19-  return 1
20+    ret=\$?
21+    unset -f current_epoch update_last_updated_file update_ohmyzsh 2>/dev/null
22+    command rm -rf '$ZSH/log/update.lock'
23+    return \$ret
24   " EXIT INT QUIT
25 
26   # Create or update .zsh-update file if missing or malformed