www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 505] New: rdmd and dmd do not correctly preserve program arguments with spaces.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=505

           Summary: rdmd and dmd do not correctly preserve program arguments
                    with spaces.
           Product: D
           Version: 0.173
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P1
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: brunodomedeiros+bugz gmail.com


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 :(


-- 
Nov 14 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=505


godaves yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|rdmd and dmd do not         |rdmd and dmd do not
                   |correctly preserve program  |correctly preserve program
                   |arguments with spaces.      |arguments with spaces.




------- Comment #1 from godaves yahoo.com  2006-11-14 21:38 -------
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


-- 
Nov 14 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=505


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla digitalmars.com  2006-12-08 02:06 -------
Fixed DMD 0.176


-- 
Dec 08 2006