Bug 10863 – [Win] executeShell() fails with spaces in cmd paths, unlike old shell()

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2013-08-20T18:26:00Z
Last change time
2014-02-09T00:28:45Z
Keywords
pull
Assigned to
dlang-bugzilla
Creator
bus_dbugzilla

Comments

Comment #0 by bus_dbugzilla — 2013-08-20T18:26:48Z
On Windows: ------------------------- import std.process; import std.stdio; void main() { // Works. However, shell() is scheduled for // deprecation in favor of executeShell() writeln( shell(`"cmd with spaces.exe" --help`) ); // Fails: // '"cmd with spaces.exe' is not recognized as an internal or external command, operable program or batch file. writeln( executeShell(`"cmd with spaces.exe" --help`).output ); } ------------------------- On Linux, the equivalent code (replacing single quotes with double quotes) works fine on both shell() and executeShell().
Comment #1 by bus_dbugzilla — 2014-02-04T22:08:55Z
Note that it also fails on windows when using escapeShellCommand (regardless of whether shell or executeShell is used): ------------------------- import std.process; import std.stdio; void main() { // Both fail writeln( shell(escapeShellCommand("path with spaces\tool.exe")) ); writeln( executeShell(escapeShellCommand("path with spaces\tool.exe")).output ); } -------------------------
Comment #2 by dlang-bugzilla — 2014-02-08T17:23:51Z
Comment #3 by github-bugzilla — 2014-02-09T00:28:24Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/e354f65e934b972339f38e35a3e6b42ba4db9114 std.process: Improve shell escaping on Windows (issue 10863) https://github.com/D-Programming-Language/phobos/commit/d48acf249a85328ea3914c2d69b3d0ece11ce4c7 Merge pull request #1915 from CyberShadow/std-process-cmd-escaping std.process: Improve shell escaping on Windows (issue 10863)