https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112018-10-05T08:29:51ZRuby Issue Tracking SystemRuby master - Bug #15204: globbing should be prevented when wildcard is surrounded by double quotes in the ruby's command linehttps://bugs.ruby-lang.org/issues/15204?journal_id=743112018-10-05T08:29:51ZLeiYuhou (Yuhou Lei)
<ul></ul><p>sorry, maybe some text was modified by the bug tracker Editor :-)<br>
In Linux's bash</p>
<pre><code class="text syntaxhl" data-language="text">$ ./tt "*.txt"
it's output is : ["*.txt"]
</code></pre>
<p>my patch's content:</p>
<pre><code class="text syntaxhl" data-language="text">Index: win32/win32.c
===================================================================
--- win32/win32.c (revision 64922)
+++ win32/win32.c (working copy)
@@ -1733,7 +1733,7 @@
// N.B. Don't glob if inside a single quoted string
//
- if (quote != L'\'')
+ if (quote != L'\'' && quote != L'"')
globbing++;
slashes = 0;
break;
</code></pre> Ruby master - Bug #15204: globbing should be prevented when wildcard is surrounded by double quotes in the ruby's command linehttps://bugs.ruby-lang.org/issues/15204?journal_id=941142021-10-12T18:47:28Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>The history indicates the current behavior is expected, and I agree. Globbing inside double quotes is not done by Linux/Unix shells, but is done on Windows:</p>
<pre><code>C:\Users\jeremye>dir /b D*
Desktop
Documents
Downloads
C:\Users\jeremye>dir /b "D*"
Desktop
Documents
Downloads
C:\Users\jeremye>dir /b 'D*'
File Not Found
</code></pre>
<p>It's better for Ruby to be consistent with the behavior of the shell on the same operating system, instead of being consistent with the shell of other operating systems. If you would like your users to have consistent behavior between Windows and Linux, you'll need to inform users to always use single quotes if they do not want globbing.</p>