Fix brace parsing bug in CLASH_DOWNLOAD_URL_TEMPLATE default value

The `}` in `{arch}` prematurely closes the `${...:-...}` parameter
expansion, causing the default URL to be truncated to
`clash-{arch.gz}` instead of `clash-{arch}.gz`. The subsequent
`{arch}` replacement then fails silently.

Extract the default URL into a separate variable to avoid the
nested brace conflict.
This commit is contained in:
Jalen Yan
2026-03-03 11:08:08 +08:00
parent 48d2d90ee5
commit 3740c60d89

View File

@ -36,7 +36,8 @@ download_clash_bin() {
return 1 return 1
fi fi
download_url="${CLASH_DOWNLOAD_URL_TEMPLATE:-https://github.com/Dreamacro/clash/releases/latest/download/clash-{arch}.gz}" local _default_url="https://github.com/Dreamacro/clash/releases/latest/download/clash-{arch}.gz"
download_url="${CLASH_DOWNLOAD_URL_TEMPLATE:-$_default_url}"
if [ -z "$download_url" ]; then if [ -z "$download_url" ]; then
echo -e "\033[33m[WARN] 未设置 CLASH_DOWNLOAD_URL_TEMPLATE跳过 Clash 内核自动下载\033[0m" echo -e "\033[33m[WARN] 未设置 CLASH_DOWNLOAD_URL_TEMPLATE跳过 Clash 内核自动下载\033[0m"
return 1 return 1