From fad34413890484f817af1853353f1617a7fc4d14 Mon Sep 17 00:00:00 2001 From: YiXuan Ding <1328032567@qq.com> Date: Fri, 25 Oct 2024 15:03:35 +0800 Subject: [PATCH] : add logic to judge whether dir exists. --- tool/install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tool/install.sh b/tool/install.sh index 173c47c..5c8ce86 100644 --- a/tool/install.sh +++ b/tool/install.sh @@ -99,6 +99,11 @@ while getopts ":hd:" option; do ;; d) install_dir=${OPTARG} + # 检查路径是否存在,如果不存在则创建该路径 + if [ ! -d "$install_dir" ]; then + echo "目录 $install_dir 不存在,正在创建..." + mkdir -p "$install_dir" || { echo "创建目录失败,请重试"; exit 1; } + fi ;; \?) echo "无效的命令行选项。使用 -h 查看帮助"