summaryrefslogtreecommitdiff
path: root/tools/upgrade.sh
diff options
context:
space:
mode:
authorMarc Cornellà <hello@mcornella.com>2021-09-15 19:06:51 +0200
committerMarc Cornellà <hello@mcornella.com>2021-09-16 17:01:58 +0200
commitb79726b1c33149a429bbade49e9567a08ffa98af (patch)
tree586b31244e7d9f5def8b5e0567356fdfaf66762c /tools/upgrade.sh
parent4bd5d03e51ae289a986ab63e94bf4e1c96a75786 (diff)
downloadzsh-b79726b1c33149a429bbade49e9567a08ffa98af.tar.gz
zsh-b79726b1c33149a429bbade49e9567a08ffa98af.tar.bz2
zsh-b79726b1c33149a429bbade49e9567a08ffa98af.zip
fix(update): silence `typeset` calls in `upgrade.sh` script (#10048)
Co-authored-by: yyny <6576327+yyny@users.noreply.github.com>
Diffstat (limited to 'tools/upgrade.sh')
-rwxr-xr-xtools/upgrade.sh11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/upgrade.sh b/tools/upgrade.sh
index e9f8bc0f9..7dec398fd 100755
--- a/tools/upgrade.sh
+++ b/tools/upgrade.sh
@@ -1,16 +1,23 @@
#!/usr/bin/env zsh
+# Protect against running with shells other than zsh
if [ -z "$ZSH_VERSION" ]; then
exec zsh "$0" "$@"
fi
+# Protect against unwanted sourcing
+case "$ZSH_EVAL_CONTEXT" in
+ *:file) echo "error: this file should not be sourced" && return ;;
+esac
+
cd "$ZSH"
# Use colors, but only if connected to a terminal
# and that terminal supports them.
-local -a RAINBOW
-local RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
+setopt typeset_silent
+typeset -a RAINBOW
+typeset RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
if [ -t 1 ]; then
RAINBOW=(