rdmd problems (OS X Leopard, DMD 2.052)

Magnus Lie Hetland magnus at hetland.org
Fri Feb 25 07:28:41 PST 2011


On 2011-02-21 15:17:44 +0100, Jacob Carlborg said:

> On 2011-02-21 14:16, Lars T. Kyllingstad wrote:
>> 
>> Say you have a file "myscript", that starts with the line
>> 
>> #!/path/to/interpreter --foo --bar
>> 
>> If you run this as
>> 
>> ./myscript --hello --world
>> 
>> then the args[] received by the interpreter program looks like this:
>> 
>> args[0] = "/path/to/interpreter"
>> args[1] = "--foo --bar"
>> args[2] = "./myscript"
>> args[3] = "--hello"
>> args[4] = "--world"
>> 
>> This is the case on every shell I've tried on Linux, at least.

Let me first clarify: By "nothing happens", I really mean that. When I 
supply --shebang, the code isn't compiled, and nothing is run. Running 
the script becomes a no-op.

As for your example: The switches to rdmd *don't* appear in args for 
me. So for example, if I have

#!/path/to/rdmd -unittest

... as the shebang line, rdmd finds and passes the -unittest switch to 
dmd (my unit tests work). I get no problems when I add more switches 
either (i.e., rdmd doesn't complain). But, as far as I can see, none of 
these end up in args. (Or are we talking about different things here?)

Instead, args[0] contains the full path to the temporary executable 
built and run by rdmd, and args[1..$] contain any arguments I supplied 
when running the script.

The fact that --shebang borks the whole execution seems like it must be 
a bug. As for the rest of the behavior, it seems pretty useful to me, 
but perhaps OS X-specific? (That would be odd, but who knows...)

-- 
Magnus Lie Hetland
http://hetland.org



More information about the Digitalmars-d-learn mailing list