From 34d4526413682238cce903e9cfc184112ab85ec7 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 7 Jun 2026 22:03:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20work=5Fdir=20=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/otask.sh | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/shell/otask.sh b/shell/otask.sh index 5712e0a5..071e6b61 100755 --- a/shell/otask.sh +++ b/shell/otask.sh @@ -104,31 +104,22 @@ enter_script_workdir() { else _target_dir="${dir_scripts}/${work_dir}" fi - if [[ ! -d "${_target_dir}" ]]; then - echo -e "错误:工作目录不存在 ${_target_dir}" - exit 1 - fi - cd "${_target_dir}" || { - echo -e "错误:无法进入工作目录 ${_target_dir}" - exit 1 - } - # 仍然处理 file_param 中的路径前缀,确保命令路径正确 - if [[ ${file_param} =~ "/" ]]; then - local script_name="${file_param##*/}" - if [[ "${use_dot_prefix}" == "true" ]]; then - file_param="./${script_name}" - else - file_param="${script_name}" + if [[ -d "${_target_dir}" ]]; then + cd "${_target_dir}" + if [[ ${file_param} =~ "/" ]]; then + local script_name="${file_param##*/}" + if [[ "${use_dot_prefix}" == "true" ]]; then + file_param="./${script_name}" + else + file_param="${script_name}" + fi fi + return fi - return + echo -e "警告:工作目录不存在 ${_target_dir}" fi - # 自动检测:从 file_param 中提取脚本所在目录 - cd $dir_scripts || { - echo -e "错误:无法进入 scripts 目录 ${dir_scripts}" - exit 1 - } + cd $dir_scripts if [[ ${file_param} =~ "/" ]]; then local script_dir="${file_param%/*}" local script_name="${file_param##*/}"