From dc302bff1cd2dfa4a4c2f0f786a4824db3a10070 Mon Sep 17 00:00:00 2001 From: laily Date: Tue, 8 Sep 2026 11:34:46 +0800 Subject: [PATCH] fix: fail mise-install when curl pipeline errors Do not print success after a failed curl | sh install; enable pipefail and verify mise is on PATH before continuing. --- script/mise-install.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/script/mise-install.sh b/script/mise-install.sh index 25b538f..43a27cd 100755 --- a/script/mise-install.sh +++ b/script/mise-install.sh @@ -20,18 +20,28 @@ EOF dotfile_help_requested "${1:-}" && dotfile_show_help -set -e +set -euo pipefail GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' NC='\033[0m' +mise_fail() { + echo -e "${RED}mise 安装失败,请检查错误信息${NC}" >&2 + exit 1 +} + if ! command -v mise &>/dev/null; then echo -e "${YELLOW}mise 未安装. 正在安装 mise...${NC}" - curl https://mise.run | sh + # 无 pipefail 时 curl 失败 sh 仍可能退出 0,会误报「安装完成」 + curl -fL --retry 3 https://mise.run | sh || mise_fail export PATH="$HOME/.local/bin:$PATH" + if ! command -v mise &>/dev/null; then + mise_fail + fi + if [ -f ~/.config/fish/config.fish ]; then if ! grep -q "mise activate" ~/.config/fish/config.fish; then echo -e "${YELLOW}正在为 fish shell 配置 mise...${NC}" @@ -72,6 +82,5 @@ fi if command -v mise &>/dev/null; then echo -e "${GREEN}mise 安装成功!${NC}" else - echo -e "${RED}mise 安装失败,请检查错误信息${NC}" - exit 1 + mise_fail fi