From 7bf5f10016ef3d99d4a6a45b6a300d04d930de2a Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 1 Jun 2015 15:22:42 +0100 Subject: mingw: add magic '--busybox' flag If BusyBox is invoked with argv[1] set to --busybox skip the first two arguments so that argv[2] becomes the applet name and argv[3] et seq are its arguments. This is needed when BusyBox is run as sh.exe and the executable is reexecuted to invoke compress/decompress applets. --- archival/libarchive/open_transformer.c | 3 ++- archival/tar.c | 2 +- libbb/appletlib.c | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c index 24524f6ee..c7ec4a74d 100644 --- a/archival/libarchive/open_transformer.c +++ b/archival/libarchive/open_transformer.c @@ -163,7 +163,8 @@ void FAST_FUNC fork_transformer(int fd, const char *transform_prog) int fd1; if (find_applet_by_name(transform_prog) >= 0) { - cmd = xasprintf("%s %s -cf -", bb_busybox_exec_path, transform_prog); + cmd = xasprintf("%s --busybox %s -cf -", bb_busybox_exec_path, + transform_prog); } else { cmd = xasprintf("%s -cf -", transform_prog); diff --git a/archival/tar.c b/archival/tar.c index 1f9dd23d2..d1b0e475d 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -685,7 +685,7 @@ static pid_t vfork_compressor(int tar_fd, const char *gzip) pid_t pid; if (find_applet_by_name(gzip) >= 0) { - cmd = xasprintf("%s %s -cf -", bb_busybox_exec_path, gzip); + cmd = xasprintf("%s --busybox %s -cf -", bb_busybox_exec_path, gzip); } else { cmd = xasprintf("%s -cf -", gzip); diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 841494a70..e99d3a5c4 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -864,6 +864,10 @@ int main(int argc UNUSED_PARAM, char **argv) applet_name = applet_name_env; unsetenv("BUSYBOX_APPLET_NAME"); } + else if ( argv[1] && argv[2] && strcmp(argv[1], "--busybox") == 0 ) { + argv += 2; + applet_name = argv[0]; + } else { char *s = argv[0]; int i, len = strlen(s); -- cgit v1.2.3-55-g6feb