[hoping this isn't a double post]

William James wrote:

> ruby.exe argvtest.rb '"quoted"'
>
> ruby.exe argvtest.rb "\"quoted\""

Thanks.  I didn't get this at first because my shell uses a caret (^)
as the escape character, not the backslash - backslash being the
directory separator on the PC.

After reading your reply, I realized I needed to go through the code to
figure out how Ruby is really behaving.  For example, the MSVC runtime
strips out all quotes not escaped by a backslash, so the first example
of '"quoted"' shouldn't have worked, yet it does.

It turns out that, under Windows, ruby.exe ignores argv and reparses it
from the raw command line. In rb_w32_cmdvector() in win32.c, the
section with the comment:

	//
	// if it's an input vector element and it's enclosed by quotes,
	// we can remove them.
	//

does just that.

This is important to me because of a project embedding Ruby, which
wasn't stripping quotes.  I passed in a quoted filename and IO#foreach
failed.  Yet the same script ran correctly with the same arguments when
called through ruby.exe.

Filenames under Windows cannon contain the double quote character, and
most of the Windows API functions work with filenames containing double
quotes by simply pretending they aren't there. (I'd say all the API
functions, but this *is* Windows, after all.)  It would be nice if Ruby
under Windows was as tolerant.

Thanks again,

-- Timothy