Merge pull request #189 from Kattos/main

- remove useless error messages when `uv` is set but no config file exists
- Fixed #188
This commit is contained in:
happy-game 2025-04-03 10:43:46 +08:00 committed by GitHub
commit 44dcebf5ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 10 deletions

View File

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

View File

@ -94,15 +94,24 @@ pl_python_uv_setsrc (char *option)
uv_config);
char *append_source_cmd = xy_strjoin (4, "printf '", source_content, "' >> ", uv_config);
// grep -q '^[[index]]$' uv_config && update_source_cmd || append_source_cmd
// 如果 uv_config 中存在 [[index]] 则更新, 否则追加到文件末尾
// 文件不存在也是追加到新文件末尾
char *cmd = xy_strjoin (6, "grep -q '^\\[\\[index\\]\\]$' ",
uv_config,
" && ",
update_source_cmd,
" || ",
append_source_cmd);
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);
}
chsrc_run (cmd, RunOpt_Default);