{"thread":{"id":"18512","subject":"[PATCH] MinGW: Quote arguments for subprocesses that contain a single-quote","startedAt":"2009-03-24T20:43:02Z","lastAt":"2009-03-24T20:43:02Z","messageCount":1,"participants":["Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"109240","messageId":"200903242143.03010.j6t@kdbg.org","threadId":"18512","inReplyTo":null,"subject":"[PATCH] MinGW: Quote arguments for subprocesses that contain a single-quote","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-03-24T20:43:02Z","receivedAt":"2009-03-24T20:43:02Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"\nBefore a process can be spawned by mingw_spawnve, arguments must be\nsurrounded by double-quotes if special characters are present.  This is\nnecessary because the startup code of the spawned process will expand\narguments that look like glob patterns.  \"Normal\" Windows command line\nutilities expand only * and ?, but MSYS programs, including bash, are\ndifferent: They also expand braces, and this has already been taken care\nof by compat/mingw.c:quote_arg().\n\nBut MSYS programs also treat single-quotes in a special way: Arguments\nbetween single-quotes are spliced together (with spaces) into a word.\nWith this patch this treatment is avoided by quoting arguments that contain\nsingle-quotes.\n\nThis lets t4252 pass on Windows.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n t4252 passes a --directory argument with a single-quote to git-am. As a\n consequence, this argument was spliced into a single word with the\n remaining arguments, including the mbox file name. Following that,\n git-mailsplit was called without a mailbox, upon which it waited for input\n on stdin.\n\n -- Hannes\n\n compat/mingw.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 171fa85..2839d9d 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -457,7 +457,7 @@ static const char *quote_arg(const char *arg)\n \tconst char *p = arg;\n \tif (!*p) force_quotes = 1;\n \twhile (*p) {\n-\t\tif (isspace(*p) || *p == '*' || *p == '?' || *p == '{')\n+\t\tif (isspace(*p) || *p == '*' || *p == '?' || *p == '{' || *p == '\\'')\n \t\t\tforce_quotes = 1;\n \t\telse if (*p == '\"')\n \t\t\tn++;\n-- \n1.6.2.1.224.g2225f\n"}]}