Skip to content

Commit

Permalink
dcrt0.cc (globify): Don't quote literal strings differently when dos_…
Browse files Browse the repository at this point in the history
…spec

Reverts 25ba8f3. I can't figure out what
the intention was. I'm sure I'll find out soon enough when everything breaks.

This change means that input of:
  '"C:/test.exe SOME_VAR=\"literal quotes\""'

becomes:
  'C:/test.exe SOME_VAR="literal quotes"'

instead of:
  'C:/test.exe SOME_VAR=\literal quotes\'

.. which is at least consistent with the result for:
  '"no_drive_or_colon SOME_VAR=\"literal quotes\""'

The old result of course resulted in the quoted string being split into
two arguments at the space which is clearly not intended.

I *guess* backslashes in dos paths may have been the issue here?
If so I don't care since we should not use them, ever, esp. not at
the expense of sensible forward-slash-containing input.
  • Loading branch information
mingwandroid authored and dscho committed Feb 27, 2024
1 parent a758d14 commit 921063a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion winsup/cygwin/dcrt0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,20 @@ globify (char *word, char **&argv, int &argc, int &argvlen)
char quote = *s;
while (*++s && *s != quote)
{
/* This used to be:
if (dos_spec || *s != '\\')
/* nothing */;
// nothing
else if (s[1] == quote || s[1] == '\\')
s++;
With commit message:
dcrt0.cc (globify): Don't use \ quoting when apparently quoting a DOS path
spec, even within a quoted string.
But that breaks the "literal quotes" part of '"C:/test.exe SOME_VAR=\"literal quotes\""'
giving: 'C:/test.exe SOME_VAR=\literal quotes\' (with \'s between each character)
instead of 'C:/test.exe SOME_VAR="literal quotes"' (with \'s between each character)
*/
if (*s == '\\' && (s[1] == quote || s[1] == '\\'))
s++;
*p++ = '\\';
size_t cnt = isascii (*s) ? 1 : mbtowc (NULL, s, MB_CUR_MAX);
if (cnt <= 1 || cnt == (size_t)-1)
Expand Down

0 comments on commit 921063a

Please sign in to comment.