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