Skip to content

Commit d60c961

Browse files
committed
Fix: existing path not writable case
1 parent 00b59ad commit d60c961

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tool/installer.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env bash
22
# ---------------------------------------------------------------
3-
# File Name : installer.sh
4-
# File Authors : GnixAij <[email protected]>
5-
6-
# | ChatGPT <https://chatgpt.com>
7-
# Contributors : Aoran Zeng <[email protected]>
3+
# File Name : installer.sh
4+
# File Authors : GnixAij <[email protected]>
5+
6+
# | ChatGPT <https://chatgpt.com>
7+
# Contributors : Aoran Zeng <[email protected]>
8+
# | GitHub Copilot <https://github.com/copilot>
89
# |
910
# Created On : <2024-10-25>
1011
# Last Modified : <2025-03-25>
1112
#
12-
# chsrc installer for Linux & macOS
13+
# chsrc installer for POSIX (mainly Linux & macOS)
1314
# ---------------------------------------------------------------
1415

1516
binary_name="chsrc"
@@ -212,6 +213,15 @@ set_install_dir() {
212213
fi
213214

214215
userOpt_install_dir=$(dirname "$existing_path")
216+
217+
if [ ! -w "$userOpt_install_dir" ]; then
218+
if is_zh; then
219+
error "目录 $userOpt_install_dir 不可写,请使用 sudo 命令运行脚本;或通过 -d 参数指定其它目录安装"
220+
else
221+
error "Directory $userOpt_install_dir is not writable. Please run the script with sudo; or specify another dir using the -d option."
222+
fi
223+
fi
224+
215225
else
216226
# 检查默认安装目录
217227
if [ -d "$default_install_dir_4root" ] && [ -w "$default_install_dir_4root" ]; then

0 commit comments

Comments
 (0)