Skip to content

Commit 7b01893

Browse files
committed
尽量消除对 system() 的直接调用
1 parent 9d1a287 commit 7b01893

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

src/recipe/lang/Python/uv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pl_python_uv_setsrc (char *option)
142142
/* 当 uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 */
143143
char *cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source, "@f@", uv_config);
144144
chsrc_ensure_program ("grep");
145-
int status = system (cmd);
145+
int status = xy_run_get_status (cmd);
146146
if (0==status)
147147
{
148148
chsrc_run (update_config_cmd, RunOpt_Default);

src/recipe/os/APT/Debian.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ os_debian_prelude ()
1010
chef_prep_this (os_debian, gsr);
1111

1212
chef_set_created_on (this, "2023-09-02");
13-
chef_set_last_updated (this, "2025-08-10");
13+
chef_set_last_updated (this, "2025-09-12");
1414
chef_set_sources_last_updated (this, "2025-07-11");
1515

1616
chef_set_chef (this, NULL);
@@ -73,7 +73,7 @@ os_debian_does_old_sourcelist_use_cdrom (void)
7373
{
7474
/* 我们只检查旧版sourcelist,因为 common.h 中的填充只支持旧版 */
7575
char *cmd = xy_2strcat ("grep -q '^deb cdrom:' ", OS_Debian_old_SourceList);
76-
int ret = system (cmd);
76+
int ret = xy_run_get_status (cmd);
7777
bool use_cdrom = ret == 0;
7878

7979
return use_cdrom;
@@ -135,7 +135,7 @@ os_debian_setsrc (char *option)
135135
if (use_cdrom)
136136
{
137137
chsrc_backup (OS_Debian_old_SourceList);
138-
int rm_status = system ("rm " OS_Debian_old_SourceList);
138+
int rm_status = xy_run_get_status ("rm " OS_Debian_old_SourceList);
139139
if (rm_status != 0) { /* Placate -Wunused-result */ }
140140

141141
chsrc_warn2 ("旧版源配置文件中使用了 CDROM 源,已删除(但备份)该配置文件,重新配置");

src/recipe/os/pacman/Arch-Linux.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ os_archlinuxcn_prelude ()
116116
chef_prep_this (os_archlinuxcn, gs);
117117

118118
chef_set_created_on (this, "2023-09-05");
119-
chef_set_last_updated (this, "2025-08-10");
119+
chef_set_last_updated (this, "2025-09-12");
120120
chef_set_sources_last_updated (this, "2024-07-03");
121121

122122
chef_set_chef (this, NULL);
@@ -133,7 +133,7 @@ os_archlinuxcn_prelude ()
133133

134134

135135
def_sources_begin()
136-
{&UpstreamProvider, "https://repo.archlinuxcn.org/", DelegateToUpstream},
136+
{&UpstreamProvider, "https://repo.archlinuxcn.org/", DelegateToUpstream},
137137
{&Ali, "https://mirrors.aliyun.com/archlinuxcn/", DelegateToMirror},
138138
{&Bfsu, "https://mirrors.bfsu.edu.cn/archlinuxcn/", DelegateToMirror},
139139
{&Ustc, "https://mirrors.ustc.edu.cn/archlinuxcn/", DelegateToMirror},
@@ -157,7 +157,6 @@ os_archlinuxcn_getsrc (char *option)
157157

158158
/**
159159
* @consult https://mirrors.tuna.tsinghua.edu.cn/help/archlinuxcn/
160-
* @update 2025-05-24
161160
*/
162161
void
163162
os_archlinuxcn_setsrc (char *option)
@@ -172,7 +171,7 @@ os_archlinuxcn_setsrc (char *option)
172171

173172
/* 检查是否已存在 archlinuxcn 配置段 */
174173
char *check_cmd = "grep -q '\\[archlinuxcn\\]' " OS_Pacman_ArchLinuxCN_MirrorList;
175-
int ret = system(check_cmd);
174+
int ret = xy_run_get_status (check_cmd);
176175

177176
if (ret == 0)
178177
{

src/recipe/ware/Homebrew/Homebrew.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ wr_homebrew_prelude ()
1212
chef_prep_this (wr_homebrew, gs);
1313

1414
chef_set_created_on (this, "2023-09-10");
15-
chef_set_last_updated (this, "2025-08-09");
15+
chef_set_last_updated (this, "2025-09-12");
1616
chef_set_sources_last_updated (this, "2025-07-13");
1717

1818
chef_set_chef (this, NULL);
@@ -39,7 +39,7 @@ wr_homebrew_prelude ()
3939
void
4040
wr_homebrew_getsrc (char *option)
4141
{
42-
int status = system (RAWSTR_wr_homebrew_read_config_cmd);
42+
int status = xy_run_get_status (RAWSTR_wr_homebrew_read_config_cmd);
4343
if (status != 0) { xy_noop(); }
4444
}
4545

0 commit comments

Comments
 (0)