remove useless error messages when uv is set but no config file exists

This commit is contained in:
cuichengyi 2025-04-02 22:11:49 +08:00
parent b560bc02aa
commit 340928f2db
2 changed files with 19 additions and 15 deletions

View File

@ -23,6 +23,7 @@
* | juzeon <skyjuzheng@gmail.com> * | juzeon <skyjuzheng@gmail.com>
* | Jialin Lyu <jialinlvcn@aliyun.com> * | Jialin Lyu <jialinlvcn@aliyun.com>
* | GitHub Copilot <https://github.com/copilot> * | GitHub Copilot <https://github.com/copilot>
* | ccy <icuichengyi@gmail.com>
* | * |
* Created On : <2023-08-28> * Created On : <2023-08-28>
* Last Modified : <2025-03-25> * Last Modified : <2025-03-25>
@ -851,4 +852,4 @@ not_matched:
chsrc_error (msg); chsrc_error (msg);
return Exit_Unknown; return Exit_Unknown;
} }
} }

View File

@ -95,20 +95,23 @@ pl_python_uv_setsrc (char *option)
char *append_source_cmd = xy_strjoin (4, "printf '", source_content, "' >> ", uv_config); char *append_source_cmd = xy_strjoin (4, "printf '", source_content, "' >> ", uv_config);
char *cmd = NULL; char *cmd = NULL;
if (!xy_file_exist(uv_config)) { if (!xy_file_exist (uv_config))
// uv_config 不存在,追加到新文件末尾 {
// run: append_source_cmd // uv_config 不存在,追加到新文件末尾
cmd = append_source_cmd; // run: append_source_cmd
} else { cmd = append_source_cmd;
// uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 }
// run: grep -q '^[[index]]$' uv_config && update_source_cmd || append_source_cmd else
cmd = xy_strjoin (6, "grep -q '^\\[\\[index\\]\\]$' ", {
uv_config, // uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾
" && ", // run: grep -q '^[[index]]$' uv_config && update_source_cmd || append_source_cmd
update_source_cmd, cmd = xy_strjoin (6, "grep -q '^\\[\\[index\\]\\]$' ",
" || ", uv_config,
append_source_cmd); " && ",
} update_source_cmd,
" || ",
append_source_cmd);
}
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);