From f4fc4fb51fcba40a5db81861629fff27d73bed85 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 7 Jul 2024 10:18:54 +0100 Subject: ash: special hack for libtool Libtool assumes the host environment is MSYS2 and will be confused by Windows-style command switches. The "/c" in "cmd /c" looks like a path, which MSYS2 incorrectly decodes to "c:/". Anticipating this, libtool encodes these calls as "cmd //c" which does not work outside MSYS2. A busybox-w32 patch makes it behave like MSYS2 in just this one case. Adds 88-96 bytes. (GitHub issue #297 and https://github.com/skeeto/w64devkit/issues/50) --- shell/ash.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shell/ash.c b/shell/ash.c index b894a2314..e2dcb0962 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -9142,6 +9142,16 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c #endif #if ENABLE_PLATFORM_MINGW32 + /* Workaround for libtool, which assumes the host is an MSYS2 + * environment and requires special-case escaping for cmd.exe. + * https://github.com/skeeto/w64devkit/issues/50 */ + if (string_array_len(argv) >= 3 && + strcmp(argv[0], "cmd") == 0 && + strcmp(argv[1], "//c") == 0 && + strcmp(argv[2], "echo") == 0) { + argv[1]++; /* drop extra slash */ + } + /* cmd was allocated on the stack with room for an extension */ add_win32_extension((char *)cmd); execve(cmd, argv, envp); -- cgit v1.2.3-55-g6feb