Jump to page: 1 2
Thread overview
D for scripting?
Jan 20, 2017
岩倉 澪
Jan 20, 2017
Jacob Carlborg
Jan 20, 2017
岩倉 澪
Jan 21, 2017
Jacob Carlborg
Jan 20, 2017
Russel Winder
Jan 22, 2017
Russel Winder
Jan 22, 2017
Dicebot
Jan 24, 2017
Russel Winder
Jan 22, 2017
Dicebot
Jan 24, 2017
Russel Winder
Jan 20, 2017
Kagamin
Jan 20, 2017
岩倉 澪
Jan 21, 2017
Chris Wright
Jan 20, 2017
Edwin van Leeuwen
Jan 20, 2017
岩倉 澪
Jan 22, 2017
Laeeth Isharc
January 20, 2017
Last weekend I tried porting some old shell scripts to D, as I think D is actually extremely well suited as a shell script replacement. My scripts are so much more robust now and do things like rolling back on errors and having debug mode, all with roughly the same amount of lines as the flimsy old shell scripts.

I have two points of feedback regarding rdmd:

* If you name your script without a .d extension, rdmd fails saying the module is in script.d which cannot be read
* rdmd doesn't seem to play nice with symlinks

I keep my scripts in ~/scripts so that I can just pull them from github and go on my merry way, with symlinks in /usr/local/bin, but rdmd doesn't -I the real directory, it does -I/usr/local/bin, and if I symlink a script.d as /usr/local/bin/script, it can't find the module.
I can pass -I/home/mio/scripts on the shebang line at least...

Furthermore, if I -J a folder with string imports I would have to type out the fully qualified path just like with -I. It would be so much more convenient if rdmd would follow the symlink to the scripts directory, change the working directory, and then compile, or something like that.

Is anyone else using D for scripting?
I feel like the shebang is totally worth it if I could name my file without .d and symlink to it. Would it be reasonable to change rdmd to allow these features? I'd be happy to look into writing a patch for it if it wouldn't be a waste of time.
January 20, 2017
On 1/20/17 3:59 AM, 岩倉 澪 wrote:
> I feel like the shebang is totally worth it if I could name my file
> without .d and symlink to it. Would it be reasonable to change rdmd to
> allow these features? I'd be happy to look into writing a patch for it
> if it wouldn't be a waste of time.

It would be worth it. I think a fix takes some thinking because if I remember correctly the compiler does not accept files without an extension as input. So rdmd would need to use a workaround - e.g. create a temporary symlink, compile, and remove the symlink. -- Andrei
January 20, 2017
On 2017-01-20 08:10, Andrei Alexandrescu wrote:

> It would be worth it. I think a fix takes some thinking because if I
> remember correctly the compiler does not accept files without an
> extension as input.

It does. It's been fixed, for exactly this reason.

-- 
/Jacob Carlborg
January 20, 2017
On Friday, 20 January 2017 at 03:59:12 UTC, 岩倉 澪 wrote:
> I keep my scripts in ~/scripts so that I can just pull them from github and go on my merry way, with symlinks in /usr/local/bin, but rdmd doesn't -I the real directory, it does -I/usr/local/bin, and if I symlink a script.d as /usr/local/bin/script, it can't find the module.
> I can pass -I/home/mio/scripts on the shebang line at least...

You can symlink ~/scripts to /usr/local/bin/scripts and -I/usr/local/bin/scripts and keep all files with .d extensions there, create only symlinks in bin without extensions.
January 20, 2017
On Fri, 2017-01-20 at 07:10 +0000, Andrei Alexandrescu via Digitalmars-
d wrote:
[…]
> 
> It would be worth it. I think a fix takes some thinking because if I
> remember correctly the compiler does not accept files without an
> extension as input. So rdmd would need to use a workaround - e.g.
> create
> a temporary symlink, compile, and remove the symlink. -- Andrei

Someone mentioned that rdmd can be separated from the dmd distribution
and distributed on it's own. I think this would be a splendid idea.
rdmd over ldc2 could then be distributed via Debian and Fedora
packaging by the people who package ldc2 for Debian and Fedora.

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

January 20, 2017
On Friday, 20 January 2017 at 03:59:12 UTC, 岩倉 澪 wrote:
> I keep my scripts in ~/scripts so that I can just pull them from github and go on my merry way, with symlinks in /usr/local/bin, but rdmd doesn't -I the real directory, it does -I/usr/local/bin, and if I symlink a script.d as /usr/local/bin/script, it can't find the module.
> I can pass -I/home/mio/scripts on the shebang line at least...

FYI dub also has a script option, which would allow you to include any dub projects in your script, e.g.:
https://github.com/Abscissa/scriptlike/blob/master/USAGE.md#a-basic-script-in-d

Of course then you'd have to turn the included .d files into a dub project.
January 20, 2017
On Friday, 20 January 2017 at 07:54:10 UTC, Jacob Carlborg wrote:
> It does. It's been fixed, for exactly this reason.

This has already been fixed? Is this fix in a stable release yet? I might not be on the latest version...

January 20, 2017
On Friday, 20 January 2017 at 12:06:32 UTC, Kagamin wrote:
> You can symlink ~/scripts to /usr/local/bin/scripts and -I/usr/local/bin/scripts and keep all files with .d extensions there, create only symlinks in bin without extensions.

Excellent idea; makes the shebang line a bit more wordy but perhaps this is better than changing the behaviour of rdmd.

January 20, 2017
On Friday, 20 January 2017 at 15:05:51 UTC, Edwin van Leeuwen wrote:
> FYI dub also has a script option, which would allow you to include any dub projects in your script, e.g.:
> https://github.com/Abscissa/scriptlike/blob/master/USAGE.md#a-basic-script-in-d
>
> Of course then you'd have to turn the included .d files into a dub project.

Wow, I had no idea dub has a script option. I'll take a look at that. Thanks for the tip.
January 21, 2017
On Fri, 20 Jan 2017 23:55:08 +0000, 岩倉 澪 wrote:

> On Friday, 20 January 2017 at 12:06:32 UTC, Kagamin wrote:
>> You can symlink ~/scripts to /usr/local/bin/scripts and -I/usr/local/bin/scripts and keep all files with .d extensions there, create only symlinks in bin without extensions.
> 
> Excellent idea; makes the shebang line a bit more wordy but perhaps this is better than changing the behaviour of rdmd.

You can edit dmd.conf to avoid adding the args to every shebang line. To avoid interfering with your other usage, you can install another copy of dmd+rdmd to another location and put your script-specific dmd.conf in that directory.
« First   ‹ Prev
1 2