Bug 505 – rdmd and dmd do not correctly preserve program arguments with spaces.
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-11-14T08:42:00Z
Last change time
2014-02-15T13:22:16Z
Assigned to
bugzilla
Creator
bruno.do.medeiros+deebugz
Comments
Comment #0 by bruno.do.medeiros+deebugz — 2006-11-14T08:42:27Z
rdmd and dmd do not correctly preserve program arguments with spaces. With a test program that prints args.length and args[1] :
$ test.exe "a b c" d
args.length: 3
args[1]: a b c
$ rdmd test.d "a b c" d
args.length: 5
args[1]: a
$ dmd -run test.d "a b c" d
args.length: 5
args[1]: a
Note: I actually depend on this in some scripts of mine which I use often, and which this bug breaks in many situations :(
Comment #1 by godaves — 2006-11-14T21:38:29Z
Linux works fine.
Here's a fix for rdmd on windows (line 104):
version (Windows)
{
exeargv ~= "\"" ~ exepath ~ "\"";
foreach(char[] arg; argv) exeargv ~= "\"" ~ arg ~ "\"";
}
else
{
exeargv ~= exepath;
foreach(char[] arg; argv) exeargv ~= arg;
}
Before the fix:
C:\Zz>rdmd_win test.d "1 2 3" 4 "567"
args.length: 6
args[1]: 1
args[2]: 2
args[3]: 3
args[4]: 4
args[5]: 567
After:
C:\Zz>rdmd_win test.d "1 2 3" 4 "567"
args.length: 4
args[1]: 1 2 3
args[2]: 4
args[3]: 567