From 8216ee321fa5f4964e33748681e59d7e36478912 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Sat, 11 Jul 2026 08:20:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(scripts):=20local=5Ftest.sh=20=E8=A2=AB=20s?= =?UTF-8?q?h(POSIX=20=E6=A8=A1=E5=BC=8F=20bash)=20=E8=B0=83=E8=B5=B7?= =?UTF-8?q?=E6=8A=A5=E8=BF=9B=E7=A8=8B=E6=9B=BF=E6=8D=A2=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E2=80=94=E2=80=94=E9=A6=96=E8=A1=8C=E5=8A=A0?= =?UTF-8?q?=E5=AE=88=E5=8D=AB=E9=87=8D=E6=89=A7=E8=A1=8C=E5=88=B0=E6=99=AE?= =?UTF-8?q?=E9=80=9A=20bash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit macOS /bin/sh = bash --posix:设 BASH_VERSION 但禁用进程替换,line 56 的 2> >(grep ...) 在解析时即报 syntax error near unexpected token '>'。守卫检测 SHELLOPTS 含 posix 或非 bash 时 exec bash 重执行,honor 脚本文档里的 'sh scripts/local_test.sh' 用法。 Co-Authored-By: Claude Fable 5 --- scripts/local_test.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/local_test.sh b/scripts/local_test.sh index d6c693e..0f0e3e3 100755 --- a/scripts/local_test.sh +++ b/scripts/local_test.sh @@ -10,6 +10,18 @@ # 版本号 = 最新 client-v* tag 的 patch+1 加 -dev 后缀(如 v1.1.4-dev), # App 内显示走 APP_VERSION dart-define(update_provider.currentAppVersion), # 与 CI 同一读取链路——本地构建不再显示 pubspec 旧版本(2026-07-04 修复)。 +# +# 本脚本用到 bash 专属特性(数组、进程替换 `>(...)`)。若被 `sh` 调起(macOS 的 +# /bin/sh 实为 bash --posix:会设 BASH_VERSION 但禁用进程替换,导致下方 xcodebuild +# 那行报 `syntax error near unexpected token '>'`),或被 dash 等非 bash 调起,则在 +# 解析到那行之前先重执行到普通模式 bash。此判断须是第一条可执行语句。 +_posix=no +case ":${SHELLOPTS:-}:" in *:posix:*) _posix=yes ;; esac +if [ -z "${BASH_VERSION:-}" ] || [ "$_posix" = yes ]; then + exec bash "$0" "$@" +fi +unset _posix + set -euo pipefail export PATH="/opt/homebrew/bin:$PATH"