why --shebang for rdmd?

Marc Schütz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 21 06:28:26 PST 2015


On Saturday, 21 November 2015 at 05:20:16 UTC, Shriramana Sharma 
wrote:
> Hello. The following code works fine for me:
>
> #! /usr/bin/env rdmd
> import std.stdio;
> void main() { writeln(2); }
>
> So what is the use of the --shebang option of rdmd? 
> http://dlang.org/rdmd.html does not shed much light on this.
>
> Thanks.

Here's the source:
https://github.com/D-Programming-Language/tools/blob/master/rdmd.d#L59-L64

Linux has a restriction for shebang lines: There can only be only 
command line argument. E.g.:

     // foo.d
     #!/usr/bin/rdmd --compiler=/usr/bin/dmd --loop

When running ./foo.d, the kernel would execute rdmd with the 
following arguments:

     ["/usr/bin/rdmd", "--compiler=/usr/bin/dmd --loop", "./foo.d"]

I.e., the entire command line after the executable is merged into 
one argument. With `--shebang`, rdmd splits the argument before 
processing it.

That's how I understand it, anyway.


More information about the Digitalmars-d-learn mailing list