MSYS2-packages/msys2-runtime-3.4/0013-strace.cc-Don-t-set-MSYS-noglob.patch
Christoph Reiter 14e5524bed Add msys2-runtime-3.4
This will be the msys2-runtime variant that still works on Win7.
2024-03-15 17:55:50 +01:00

70 lines
2.6 KiB
Diff

From e1510e606a89af0890bb6bae8a944eea3d42857c Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Sun, 23 Aug 2015 20:47:30 +0100
Subject: [PATCH 13/N] strace.cc: Don't set MSYS=noglob
Commit message for this code was:
* strace.cc (create_child): Set CYGWIN=noglob when starting new process so that
Cygwin will leave already-parsed the command line alonw."
I can see no reason for it and it badly breaks the ability to use
strace.exe to investigate calling a Cygwin program from a Windows
program, for example:
strace mingw32-make.exe
.. where mingw32-make.exe finds sh.exe and uses it as the shell.
The reason it badly breaks this use-case is because dcrt0.cc depends
on globbing to happen to parse commandlines from Windows programs;
irrespective of whether they contain any glob patterns or not.
See quoted () comment:
"This must have been run from a Windows shell, so preserve
quotes for globify to play with later."
---
winsup/utils/mingw/strace.cc | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/winsup/utils/mingw/strace.cc b/winsup/utils/mingw/strace.cc
index a875bf2..cdfc3d6 100644
--- a/winsup/utils/mingw/strace.cc
+++ b/winsup/utils/mingw/strace.cc
@@ -354,10 +354,28 @@ create_child (char **argv)
make_command_line (one_line, argv);
SetConsoleCtrlHandler (NULL, 0);
+/* Commit message for this code was:
+"* strace.cc (create_child): Set CYGWIN=noglob when starting new process so that
+
+ Cygwin will leave already-parsed the command line alonw."
+
+ I can see no reason for it and it badly breaks the ability to use
+ strace.exe to investigate calling a Cygwin program from a Windows
+ program, for example:
+ strace mingw32-make.exe
+ .. where mingw32-make.exe finds sh.exe and uses it as the shell.
+ The reason it badly breaks this use-case is because dcrt0.cc depends
+ on globbing to happen to parse commandlines from Windows programs;
+ irrespective of whether they contain any glob patterns or not.
+
+ See quoted () comment:
+ "This must have been run from a Windows shell, so preserve
+ quotes for globify to play with later."
+
const char *cygwin_env = getenv ("MSYS");
const char *space;
- if (cygwin_env && strlen (cygwin_env) <= 256) /* sanity check */
+ if (cygwin_env && strlen (cygwin_env) <= 256) // sanity check
space = " ";
else
space = cygwin_env = "";
@@ -365,6 +383,7 @@ create_child (char **argv)
+ strlen (space) + strlen (cygwin_env));
sprintf (newenv, "MSYS=noglob%s%s", space, cygwin_env);
_putenv (newenv);
+*/
ret = CreateProcess (0, one_line.buf, /* command line */
NULL, /* Security */
NULL, /* thread */