MSYS2-packages/msys2-runtime-3.6/0017-dcrt0.cc-Untangle-allow_glob-from-winshell.patch
2025-03-31 07:42:01 +02:00

78 lines
2.9 KiB
Diff

From b39f7809fb41b50159a717978478e74d96c01819 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Fri, 21 Aug 2015 12:52:09 +0100
Subject: [PATCH 17/N] dcrt0.cc: Untangle allow_glob from winshell
Otherwise if globbing is allowed and we get called from a
Windows program, build_argv thinks we've been called from
a Cygwin program.
---
winsup/cygwin/dcrt0.cc | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index e19b7d3..8fc3672 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -154,12 +154,12 @@ isquote (char c)
/* Step over a run of characters delimited by quotes */
static /*__inline*/ char *
-quoted (char *cmd, int winshell)
+quoted (char *cmd, int winshell, int glob)
{
char *p;
char quote = *cmd;
- if (!winshell)
+ if (!winshell || !glob)
{
char *p;
strcpy (cmd, cmd + 1);
@@ -169,8 +169,8 @@ quoted (char *cmd, int winshell)
}
const char *s = quote == '\'' ? "'" : "\\\"";
- /* This must have been run from a Windows shell, so preserve
- quotes for globify to play with later. */
+ /* This must have been run from a Windows shell and globbing is enabled,
+ so preserve quotes for globify to play with later. */
while (*cmd && *++cmd)
if ((p = strpbrk (cmd, s)) == NULL)
{
@@ -292,7 +292,7 @@ globify (char *word, char **&argv, int &argc, int &argvlen)
/* Build argv, argc from string passed from Windows. */
static void
-build_argv (char *cmd, char **&argv, int &argc, int winshell)
+build_argv (char *cmd, char **&argv, int &argc, int winshell, int glob)
{
int argvlen = 0;
int nesting = 0; // monitor "nesting" from insert_file
@@ -326,7 +326,7 @@ build_argv (char *cmd, char **&argv, int &argc, int winshell)
a Cygwin process, or if the word starts with a '@'.
In this case, the insert_file function needs an unquoted
DOS filename and globbing isn't performed anyway. */
- cmd = quoted (cmd, winshell && argc > 0 && *word != '@');
+ cmd = quoted (cmd, winshell && argc > 0 && *word != '@', glob);
}
if (issep (*cmd)) // End of argument if space
break;
@@ -352,7 +352,7 @@ build_argv (char *cmd, char **&argv, int &argc, int winshell)
}
/* Add word to argv file after (optional) wildcard expansion. */
- if (!winshell || !argc || !globify (word, argv, argc, argvlen))
+ if (!glob || !argc || !globify (word, argv, argc, argvlen))
{
debug_printf ("argv[%d] = '%s'", argc, word);
argv[argc++] = word;
@@ -907,6 +907,7 @@ dll_crt0_1 (void *)
/* Scan the command line and build argv. Expand wildcards if not
called from another cygwin process. */
build_argv (line, __argv, __argc,
+ NOTSTATE (myself, PID_CYGPARENT),
NOTSTATE (myself, PID_CYGPARENT) && allow_glob);
/* Convert argv[0] to posix rules if it's currently blatantly