From d4ab7e0ec605d585190e93f7dfae821913a609ae Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Sat, 14 Dec 2024 18:09:45 +0800 Subject: [PATCH] Settle the situation that busybox cp has no `--version` [GitHub #152] --- src/framework/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/framework/core.c b/src/framework/core.c index 856acad..63c598a 100644 --- a/src/framework/core.c +++ b/src/framework/core.c @@ -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")) {