From e060327de43c83ed0d2403df81b5eca2bf5143bb Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Sun, 16 Aug 2026 09:37:06 -0600 Subject: [PATCH] =?UTF-8?q?fix(=E9=83=A8=E7=BD=B2=E8=84=9A=E6=9C=AC):=20`s?= =?UTF-8?q?h=20docker/deploy.sh`=20=E4=BC=9A=E6=8C=82=E5=9C=A8=20pipefail?= =?UTF-8?q?=EF=BC=8C=E8=87=AA=E5=B7=B1=E6=8D=A2=20bash=20=E9=87=8D?= =?UTF-8?q?=E8=B7=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debian 的 /bin/sh 是 dash,没有 pipefail,一上来就 `Illegal option -o pipefail`。 在 set 之前加一行守卫,非 bash 就 exec 换 bash 重新执行(只用 dash 也认的语法)。 实测:本机 /bin/sh 指向 bash,所以这条得在容器里的真 dash 上验 —— 带守卫的版本正常往下跑(停在 docker/.env 不存在,因为只挂了脚本没挂仓库); 去掉守卫的对照版本在 dash 下直接 Bad substitution + 语法错误。 Co-Authored-By: Claude Opus 5 --- docker/deploy.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker/deploy.sh b/docker/deploy.sh index 03af030..22af2eb 100755 --- a/docker/deploy.sh +++ b/docker/deploy.sh @@ -15,6 +15,11 @@ # # 前提:docker/.env 已经填好(内容见 docs/specs/phase5-cutover-runbook.md 第三节)。 +# `sh docker/deploy.sh` 会用 dash 跑(Debian 的 /bin/sh 就是 dash),而下面那行 +# 的 pipefail 是 bash 专有的,一上来就报 `Illegal option -o pipefail`。 +# 这行必须在 set 之前,且只能用 dash 也认的语法。 +[ -n "${BASH_VERSION:-}" ] || exec bash "$0" "$@" + set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/.."