Skip to content

Commit b560bc0

Browse files
committed
remove useless error messages when uv is set but no config file exists
1 parent b70e0c4 commit b560bc0

File tree

1 file changed

+15
-9
lines changed
  • src/recipe/lang/Python

1 file changed

+15
-9
lines changed

src/recipe/lang/Python/uv.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,21 @@ pl_python_uv_setsrc (char *option)
9494
uv_config);
9595
char *append_source_cmd = xy_strjoin (4, "printf '", source_content, "' >> ", uv_config);
9696

97-
// grep -q '^[[index]]$' uv_config && update_source_cmd || append_source_cmd
98-
// 如果 uv_config 中存在 [[index]] 则更新, 否则追加到文件末尾
99-
// 文件不存在也是追加到新文件末尾
100-
char *cmd = xy_strjoin (6, "grep -q '^\\[\\[index\\]\\]$' ",
101-
uv_config,
102-
" && ",
103-
update_source_cmd,
104-
" || ",
105-
append_source_cmd);
97+
char *cmd = NULL;
98+
if (!xy_file_exist(uv_config)) {
99+
// uv_config 不存在,追加到新文件末尾
100+
// run: append_source_cmd
101+
cmd = append_source_cmd;
102+
} else {
103+
// uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾
104+
// run: grep -q '^[[index]]$' uv_config && update_source_cmd || append_source_cmd
105+
cmd = xy_strjoin (6, "grep -q '^\\[\\[index\\]\\]$' ",
106+
uv_config,
107+
" && ",
108+
update_source_cmd,
109+
" || ",
110+
append_source_cmd);
111+
}
106112

107113
chsrc_run (cmd, RunOpt_Default);
108114

0 commit comments

Comments
 (0)