修复 work_dir 目录判断

This commit is contained in:
whyour 2026-06-07 22:03:48 +08:00
parent ad92e0c2c0
commit 34d4526413

View File

@ -104,15 +104,8 @@ enter_script_workdir() {
else else
_target_dir="${dir_scripts}/${work_dir}" _target_dir="${dir_scripts}/${work_dir}"
fi fi
if [[ ! -d "${_target_dir}" ]]; then if [[ -d "${_target_dir}" ]]; then
echo -e "错误:工作目录不存在 ${_target_dir}" cd "${_target_dir}"
exit 1
fi
cd "${_target_dir}" || {
echo -e "错误:无法进入工作目录 ${_target_dir}"
exit 1
}
# 仍然处理 file_param 中的路径前缀,确保命令路径正确
if [[ ${file_param} =~ "/" ]]; then if [[ ${file_param} =~ "/" ]]; then
local script_name="${file_param##*/}" local script_name="${file_param##*/}"
if [[ "${use_dot_prefix}" == "true" ]]; then if [[ "${use_dot_prefix}" == "true" ]]; then
@ -123,12 +116,10 @@ enter_script_workdir() {
fi fi
return return
fi fi
echo -e "警告:工作目录不存在 ${_target_dir}"
fi
# 自动检测:从 file_param 中提取脚本所在目录 cd $dir_scripts
cd $dir_scripts || {
echo -e "错误:无法进入 scripts 目录 ${dir_scripts}"
exit 1
}
if [[ ${file_param} =~ "/" ]]; then if [[ ${file_param} =~ "/" ]]; then
local script_dir="${file_param%/*}" local script_dir="${file_param%/*}"
local script_name="${file_param##*/}" local script_name="${file_param##*/}"