重命名为 xy_quiet_cmd()

This commit is contained in:
Aoran Zeng 2025-08-27 15:13:15 +08:00
parent cf07b13776
commit 9f52a4d2be
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
6 changed files with 23 additions and 26 deletions

View File

@ -491,19 +491,6 @@ xy_streql_ic(const char *str1, const char *str2)
}
static char *
xy_str_to_quietcmd (const char *cmd)
{
char *ret = NULL;
#ifdef _WIN32
ret = xy_2strcat (cmd, " >nul 2>nul ");
#else
ret = xy_2strcat (cmd, " 1>/dev/null 2>&1 ");
#endif
return ret;
}
/**
* @flavor Ruby: String#end_with?
*/
@ -776,9 +763,23 @@ _xy_log_brkt (int level, const char *prompt1, const char *prompt2, const char *c
/******************************************************
* System
* cross OS
******************************************************/
static char *
xy_quiet_cmd (const char *cmd)
{
char *ret = NULL;
if (xy.on_windows)
ret = xy_2strcat (cmd, " >nul 2>nul ");
else
ret = xy_2strcat (cmd, " 1>/dev/null 2>&1 ");
return ret;
}
/**
* @brief `cmd` `func`
*
@ -845,7 +846,7 @@ xy_run (const char *cmd, unsigned long n)
int
xy_run_get_status (char *cmd)
{
char * command = xy_str_to_quietcmd (cmd);
char * command = xy_quiet_cmd (cmd);
int status = system (command);
return status;
@ -896,10 +897,6 @@ xy_run_get_stdout (const char *cmd, char **output)
}
/******************************************************
* cross OS
******************************************************/
/**
* @flavor just os_family() windows, unix
*

View File

@ -443,7 +443,7 @@ cli_print_issues ()
/*
if (chsrc_check_program ("gh"))
{
char *cmd = xy_str_to_quietcmd ("gh browse --repo RubyMetric/chsrc");
char *cmd = xy_quiet_cmd ("gh browse --repo RubyMetric/chsrc");
system (cmd);
}
*/

View File

@ -383,7 +383,7 @@ cmd_to_check_program (char *prog_name)
{
char *check_tool = xy.on_windows ? "where " : "command -v ";
char *quiet_cmd = xy_str_to_quietcmd (xy_2strcat (check_tool, prog_name));
char *quiet_cmd = xy_quiet_cmd (xy_2strcat (check_tool, prog_name));
return quiet_cmd;
}
@ -402,7 +402,7 @@ XY_Deprecate_This("Use cmd_to_check_program() instead")
static char *
cmd_to_check_program2 (char *prog_name)
{
char *quiet_cmd = xy_str_to_quietcmd (xy_2strcat (prog_name, " --version"));
char *quiet_cmd = xy_quiet_cmd (xy_2strcat (prog_name, " --version"));
return quiet_cmd;
}
@ -1595,7 +1595,7 @@ chsrc_ensure_dir (const char *dir)
mkdir_cmd = "mkdir -p ";
}
char *cmd = xy_2strcat (mkdir_cmd, dir);
cmd = xy_str_to_quietcmd (cmd);
cmd = xy_quiet_cmd (cmd);
chsrc_run_as_a_service (cmd);

View File

@ -53,7 +53,7 @@ pl_go_prelude ()
void
pl_go_check_cmd ()
{
char *check_cmd = xy_str_to_quietcmd ("go version");
char *check_cmd = xy_quiet_cmd ("go version");
bool exist = query_program_exist (check_cmd, "go", Noisy_When_Exist|Noisy_When_NonExist);
if (!exist)

View File

@ -78,7 +78,7 @@ pl_js_yarn_setsrc (char *option)
// 不能直接退出,因为 Leader target 不能就此结束
return;
}
// 不再阻止换源命令输出到终端,即不再调用 xy_str_to_quietcmd()
// 不再阻止换源命令输出到终端,即不再调用 xy_quiet_cmd()
cmd = xy_2strcat ("yarn config set registry ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
}

View File

@ -75,7 +75,7 @@ os_freebsd_setsrc (char *option)
// @ccmywish: 2023-09-27 据 @ykla , NJU的freebsd-ports源没有设置 Git
// 但是我认为由于使用Git还是要比非Git方便许多我们尽可能坚持使用Git
// 而 gitup 又要额外修改它自己的配置,比较麻烦
bool git_exist = query_program_exist (xy_str_to_quietcmd ("git version"), "git", Noisy_When_Exist|Noisy_When_NonExist);
bool git_exist = query_program_exist (xy_quiet_cmd ("git version"), "git", Noisy_When_Exist|Noisy_When_NonExist);
if (git_exist)
{
if (xy_streql("nju",source.mirror->code))