diff --git a/script/deploy-lib.cjs b/script/deploy-lib.cjs index c0a3747..c95c474 100644 --- a/script/deploy-lib.cjs +++ b/script/deploy-lib.cjs @@ -220,10 +220,12 @@ function buildSshBaseArgs(config) { } function runSsh(config, remoteScript, options = {}) { + // Base64 编码脚本传给远端 bash,避免 shell 嵌套引用和输出信号问题 + const encoded = Buffer.from(remoteScript, 'utf8').toString('base64'); const args = [ ...buildSshBaseArgs(config), `${config.username}@${config.host}`, - `bash -c ${quoteForBash(remoteScript)}`, + `echo ${quoteForBash(encoded)} | base64 -d | bash`, ]; return runCommand('ssh', args, {