diff --git a/src/framework/core.c b/src/framework/core.c index 364b1e6..94ac56e 100644 --- a/src/framework/core.c +++ b/src/framework/core.c @@ -10,7 +10,7 @@ * | BingChunMoLi * | * Created On : <2023-08-29> - * Last Modified : <2025-08-27> + * Last Modified : <2025-09-12> * * chsrc framework * ------------------------------------------------------------*/ @@ -1348,6 +1348,28 @@ chsrc_run_as_a_service (const char *cmd) } +/** + * @brief 以纯粹的方式直接运行命令,不做任何多余处理, + * 命令执行前显示给用户,并保留所有输出给用户 + * + * @return 返回命令的退出状态 + */ +int +chsrc_run_directly (const char *cmd) +{ + if (ENGLISH) + xy_log_brkt (blue (App_Name), bdblue ("RUN"), blue (cmd)); + else + xy_log_brkt (blue (App_Name), bdblue ("运行"), blue (cmd)); + + if (in_dry_run_mode()) + { + return 0; // Dry Run 此时立即结束,并不真正执行 + } + int status = system (cmd); + return status; +} + /** * @brief 在本目录创建一个临时文件 diff --git a/src/recipe/lang/Python/pip.c b/src/recipe/lang/Python/pip.c index 81b2ea4..4fdf0ca 100644 --- a/src/recipe/lang/Python/pip.c +++ b/src/recipe/lang/Python/pip.c @@ -10,7 +10,7 @@ pl_python_pip_prelude (void) chef_prep_this (pl_python_pip, gsr); chef_set_created_on (this, "2023-09-03"); - chef_set_last_updated (this, "2025-09-10"); + chef_set_last_updated (this, "2025-09-12"); chef_set_sources_last_updated (this, "2025-07-11"); chef_set_chef (this, NULL); @@ -31,12 +31,13 @@ pl_python_pip_getsrc (char *option) char *py_prog_name = NULL; pl_python_get_py_program_name (&py_prog_name); - char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url 2>/dev/null"); - - int status = system (cmd); + char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url"); + + int status = chsrc_run_directly (cmd); if (0 == status) { // 执行成功时显示当前源 + xy_noop (); } else { @@ -45,9 +46,9 @@ pl_python_pip_getsrc (char *option) chsrc_note2 ("No source configured in pip, showing default upstream source:"); else chsrc_note2 ("pip 中未配置源,显示默认上游源:"); - + Source_t default_source = chsrc_yield_source (&pl_python_group_target, "upstream"); - chsrc_log (default_source.url); + say (default_source.url); } }