Settle the situation that busybox cp has no --version

[GitHub #152]
This commit is contained in:
Aoran Zeng
2024-12-14 18:09:45 +08:00
parent 6ded3380e5
commit d4ab7e0ec6

View File

@@ -1284,7 +1284,14 @@ chsrc_backup (const char *path)
}
else
{
char *ver = xy_run (xy_str_to_quietcmd ("cp --version"), 1);
/**
* @see https://github.com/RubyMetric/chsrc/issues/152#issuecomment-2542673273
*
* busybox cp 会在 stderr 输出 unrecognized option: version
* stderr 导入到 stdout以便我们 xy_run() 可以接受到输出
*
*/
char *ver = xy_run ("cp --version 2>&1", 1);
/* cp (GNU coreutils) 9.4 */
if (strstr (ver, "GNU coreutils"))
{