Skip to content

Commit

Permalink
fix(update): fix error exit code on update check (ohmyzsh#10033)
Browse files Browse the repository at this point in the history
This patch removes the 'exit 1' status code when the update check
finishes or is ended with CTRL+C.

Fixes ohmyzsh#10033
  • Loading branch information
mcornella authored and kareefardi committed Jul 16, 2021
1 parent 51089db commit d3ec0e8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tools/check_for_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ function update_ohmyzsh() {
return
fi

# Remove lock directory on exit. `return 1` is important for when trapping a SIGINT:
# Remove lock directory on exit. `return $ret` is important for when trapping a SIGINT:
# The return status from the function is handled specially. If it is zero, the signal is
# assumed to have been handled, and execution continues normally. Otherwise, the shell
# will behave as interrupted except that the return status of the trap is retained.
# This means that for a CTRL+C, the trap needs to return the same exit status so that
# the shell actually exits what it's running.
trap "
unset -f current_epoch update_last_updated_file update_ohmyzsh
command rm -rf '$ZSH/log/update.lock'
return 1
ret=\$?
unset -f current_epoch update_last_updated_file update_ohmyzsh 2>/dev/null
command rm -rf '$ZSH/log/update.lock'
return \$ret
" EXIT INT QUIT

# Create or update .zsh-update file if missing or malformed
Expand Down

0 comments on commit d3ec0e8

Please sign in to comment.