1diff --git a/tools/upgrade.sh b/tools/upgrade.sh
2index e9f8bc0f91a3ce810fd5e726ae5b131954b609f7..7dec398fd6f8f93638c7796753bd32b6257e7ec0 100755
3--- a/tools/upgrade.sh
4+++ b/tools/upgrade.sh
5@@ -1,16 +1,23 @@
6 #!/usr/bin/env zsh
7 8+# Protect against running with shells other than zsh
9 if [ -z "$ZSH_VERSION" ]; then
10 exec zsh "$0" "$@"
11 fi
1213+# Protect against unwanted sourcing
14+case "$ZSH_EVAL_CONTEXT" in
15+ *:file) echo "error: this file should not be sourced" && return ;;
16+esac
17+
18 cd "$ZSH"
1920 # Use colors, but only if connected to a terminal
21 # and that terminal supports them.
2223-local -a RAINBOW
24-local RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
25+setopt typeset_silent
26+typeset -a RAINBOW
27+typeset RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
2829 if [ -t 1 ]; then
30 RAINBOW=(