Skip to content

In std.process.ArgIteratorWindows, don't treat unclosed quotes like they're escaped#5667

Merged
andrewrk merged 2 commits intoziglang:masterfrom
cartr:windows-arguments-unclosed-quote
Jun 23, 2020
Merged

In std.process.ArgIteratorWindows, don't treat unclosed quotes like they're escaped#5667
andrewrk merged 2 commits intoziglang:masterfrom
cartr:windows-arguments-unclosed-quote

Conversation

@cartr
Copy link
Contributor

@cartr cartr commented Jun 22, 2020

Currently, if std.process.ArgIteratorWindows's argument parser sees a quotation mark that doesn't have a corresponding closing quote, it acts like it's escaped. For example, a b "c d is parsed as four arguments: a, b, "c, d.

This PR removes this behavior, so a b "c d is instead parsed as three arguments: a, b, c d. This better matches the way other Windows commands parse arguments---TYPE "a b.txt prints the contents of a file called a b.txt---and the way CommandLineToArgvW works. This also makes ArgIteratorWindows a little simpler/faster since it no longer needs to count the total number of quotation marks in the command line.

(It's possible the current behavior was introduced because if you pass a string like ab"cd to CommandLineToArgvW, the returned string includes the quotation mark. But I think this is because of a different oddity in CommandLineToArgvW -- see #2222 (comment) -- and it doesn't happen if you pass a string like a b"cd that has a space somewhere before the quotation mark.)

@andrewrk andrewrk merged commit 78c6d39 into ziglang:master Jun 23, 2020
@andrewrk
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants