浏览代码

fix(update): silence `typeset` calls in `upgrade.sh` script (#10048)

Co-authored-by: yyny <6576327+yyny@users.noreply.github.com>
Marc Cornellà 3 年之前
父节点
当前提交
b79726b1c3
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9 2
      tools/upgrade.sh

+ 9 - 2
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=(