From 40f0a967553191e24383f6cd8ee60a1680b7ba2d Mon Sep 17 00:00:00 2001 From: cuichengyi Date: Wed, 2 Apr 2025 12:58:02 +0800 Subject: [PATCH] fix config error in `uv.toml` --- src/recipe/lang/Python/uv.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/recipe/lang/Python/uv.c b/src/recipe/lang/Python/uv.c index d337e01..9eb6672 100644 --- a/src/recipe/lang/Python/uv.c +++ b/src/recipe/lang/Python/uv.c @@ -2,9 +2,9 @@ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------- * File Authors : happy game - * Contributors : Nul None + * Contributors : ccy * Created On : <2024-12-11> - * Last Modified : <2024-12-11> + * Last Modified : <2025-04-02> * ------------------------------------------------------------*/ @@ -81,13 +81,18 @@ pl_python_uv_setsrc (char *option) // sed -i '/^\[\[index\]\]$/,/^default = true$/{s|^url = ".*"$|url = " source.url "|}' uv_config // 将 [[index]] 到 default = true 之间的 url = ".*" 替换为 url = "source.url" - char *update_source_cmd = xy_strjoin (5, "sed -i ", +#if xy_on_macos + char *sed_cmd = "sed -i '' "; +#else + char *sed_cmd = "sed -i "; +#endif + + char *update_source_cmd = xy_strjoin (5, sed_cmd, "'/^\\[\\[index\\]\\]$/,/^default = true$/{s|^url = \".*\"$|url = \"", source.url, - "\"|}' ", + "\"|;}' ", uv_config); - - char *append_source_cmd = xy_strjoin (4, "echo -e '", source_content, "' >> ", 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]] 则更新, 否则追加到文件末尾 @@ -138,4 +143,4 @@ pl_python_uv_feat (char *option) } // def_target_gsrf(pl_python_uv); -Target_t pl_python_uv_target = {def_target_inner_gsrf(pl_python_uv),def_target_sourcesn(pl_python)}; +Target_t pl_python_uv_target = {def_target_inner_gsrf(pl_python_uv),def_target_sourcesn(pl_python)}; \ No newline at end of file