From 340928f2dbe59d3f1594b7b7e005e4178843b25e Mon Sep 17 00:00:00 2001 From: cuichengyi Date: Wed, 2 Apr 2025 22:11:49 +0800 Subject: [PATCH] remove useless error messages when `uv` is set but no config file exists --- src/chsrc-main.c | 3 ++- src/recipe/lang/Python/uv.c | 31 +++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/chsrc-main.c b/src/chsrc-main.c index b7b5d30..7b67aff 100644 --- a/src/chsrc-main.c +++ b/src/chsrc-main.c @@ -23,6 +23,7 @@ * | juzeon * | Jialin Lyu * | GitHub Copilot + * | ccy * | * Created On : <2023-08-28> * Last Modified : <2025-03-25> @@ -851,4 +852,4 @@ not_matched: chsrc_error (msg); return Exit_Unknown; } -} +} \ No newline at end of file diff --git a/src/recipe/lang/Python/uv.c b/src/recipe/lang/Python/uv.c index d97afc1..91895b5 100644 --- a/src/recipe/lang/Python/uv.c +++ b/src/recipe/lang/Python/uv.c @@ -95,20 +95,23 @@ pl_python_uv_setsrc (char *option) char *append_source_cmd = xy_strjoin (4, "printf '", source_content, "' >> ", uv_config); char *cmd = NULL; - if (!xy_file_exist(uv_config)) { - // uv_config 不存在,追加到新文件末尾 - // run: append_source_cmd - cmd = append_source_cmd; - } else { - // uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 - // run: grep -q '^[[index]]$' uv_config && update_source_cmd || append_source_cmd - cmd = xy_strjoin (6, "grep -q '^\\[\\[index\\]\\]$' ", - uv_config, - " && ", - update_source_cmd, - " || ", - append_source_cmd); - } + if (!xy_file_exist (uv_config)) + { + // uv_config 不存在,追加到新文件末尾 + // run: append_source_cmd + cmd = append_source_cmd; + } + else + { + // uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 + // run: grep -q '^[[index]]$' uv_config && update_source_cmd || append_source_cmd + cmd = xy_strjoin (6, "grep -q '^\\[\\[index\\]\\]$' ", + uv_config, + " && ", + update_source_cmd, + " || ", + append_source_cmd); + } chsrc_run (cmd, RunOpt_Default);