https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112023-11-13T20:35:26ZRuby Issue Tracking SystemRuby master - Bug #11142: Command line argument parser on windows handles double quotes inconsistently.https://bugs.ruby-lang.org/issues/11142?journal_id=1053122023-11-13T20:35:26Zpcai (Peter Cai)
<ul></ul><p>Is there a reason the windows parsing doesn't match the linux behavior?:</p>
<pre><code>vscode ➜ /workspaces/ruby (master) $ ruby -e "puts ARGV" "foo""bar"
foobar
vscode ➜ /workspaces/ruby (master) $ ruby -e "puts ARGV" "foo"" bar"
foo bar
</code></pre>
<p>And if so, can someone clarify if "treat two double quotes as a literal double quote" is correct? I think the referenced code block <a href="https://github.com/ruby/ruby/blob/bbfd735b887de71de48c7f862e6e3842bcc03241/win32/win32.c#L1745" class="external">reads as</a>:</p>
<pre><code> case '\"':
if (!quote)
quote = *ptr;
else if (quote == *ptr)
quote = '\0';
ptr++;
break;
</code></pre>
<p>Note that <code>quote</code> is initially '\0' and therefore it seems that upon encountering a second double quote, <code>if (quote == *ptr)</code> will always be true, so it seems gratuitous?</p>