www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - why --shebang for rdmd?

reply Shriramana Sharma <samjnaa_dont_spam_me gmail.com> writes:
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.

-- 
Shriramana Sharma, Penguin #395953
Nov 20 2015
parent Marc =?UTF-8?B?U2Now7x0eg==?= <schuetzm gmx.net> writes:
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.
Nov 21 2015