digitalmars.D - D for scripting?
- =?UTF-8?B?5bKp5YCJIOa+qg==?= (25/25) Jan 19 2017 Last weekend I tried porting some old shell scripts to D, as I
- Andrei Alexandrescu (5/9) Jan 19 2017 It would be worth it. I think a fix takes some thinking because if I
- Jacob Carlborg (4/7) Jan 19 2017 It does. It's been fixed, for exactly this reason.
- =?UTF-8?B?5bKp5YCJIOa+qg==?= (3/4) Jan 20 2017 This has already been fixed? Is this fix in a stable release yet?
- Jacob Carlborg (4/6) Jan 21 2017 It's fixed in DMD, _not_ in RDMD.
- Russel Winder via Digitalmars-d (19/25) Jan 20 2017 On Fri, 2017-01-20 at 07:10 +0000, Andrei Alexandrescu via Digitalmars-
- Andrei Alexandrescu (4/17) Jan 21 2017 rdmd is a single-file program distributed under a very permissive
- Russel Winder via Digitalmars-d (29/33) Jan 22 2017 On Sat, 2017-01-21 at 11:30 -0500, Andrei Alexandrescu via Digitalmars-
- Andrei Alexandrescu (4/17) Jan 22 2017 It's also the simplest to solve. Should be Boost. Please create a PR
- Dicebot (4/7) Jan 22 2017 RDMD does have license statement already
- Russel Winder via Digitalmars-d (16/24) Jan 24 2017 The repository README.md needs to state what the licence is for the
- Andrei Alexandrescu (2/3) Jan 24 2017 Affirmative.
- Dicebot (4/8) Jan 22 2017 Some time ago I have been packaging tools from that repo build
- Russel Winder via Digitalmars-d (13/23) Jan 24 2017 Perhaps we can convince the people packaging LDC for Debian and Fedora
- Kagamin (4/10) Jan 20 2017 You can symlink ~/scripts to /usr/local/bin/scripts and
- =?UTF-8?B?5bKp5YCJIOa+qg==?= (3/6) Jan 20 2017 Excellent idea; makes the shebang line a bit more wordy but
- Chris Wright (5/12) Jan 20 2017 You can edit dmd.conf to avoid adding the args to every shebang line. To...
- Edwin van Leeuwen (6/12) Jan 20 2017 FYI dub also has a script option, which would allow you to
- =?UTF-8?B?5bKp5YCJIOa+qg==?= (4/9) Jan 20 2017 Wow, I had no idea dub has a script option. I'll take a look at
- Laeeth Isharc (6/22) Jan 22 2017 No comments on rdmd, but have you tried using dub instead of rdmd
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.
Jan 19 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
Jan 19 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
Jan 19 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...
Jan 20 2017
On 2017-01-21 00:52, 岩倉 澪 wrote:This has already been fixed? Is this fix in a stable release yet? I might not be on the latest version...It's fixed in DMD, _not_ in RDMD. -- /Jacob Carlborg
Jan 21 2017
On Fri, 2017-01-20 at 07:10 +0000, Andrei Alexandrescu via Digitalmars- d wrote: [=E2=80=A6]=20 It would be worth it. I think a fix takes some thinking because if I=C2==A0remember correctly the compiler does not accept files without an=C2=A0 extension as input. So rdmd would need to use a workaround - e.g. create=C2=A0 a temporary symlink, compile, and remove the symlink. -- AndreiSomeone 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. =20 --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 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
Jan 20 2017
On 01/20/2017 09:15 AM, Russel Winder via Digitalmars-d wrote:On Fri, 2017-01-20 at 07:10 +0000, Andrei Alexandrescu via Digitalmars- d wrote: […]rdmd is a single-file program distributed under a very permissive license. Would you care to repackage it the way you find more appropriate? -- AndreiIt 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. -- AndreiSomeone 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.
Jan 21 2017
On Sat, 2017-01-21 at 11:30 -0500, Andrei Alexandrescu via Digitalmars- d wrote: [=E2=80=A6]=20 rdmd is a single-file program distributed under a very permissive=C2=A0 license. Would you care to repackage it the way you find more=C2=A0 appropriate? -- AndreiThe "problem" here is the role of the D Tools repository. Is it solely for DMD, or is it supposed to be something that can be packaged independent of a particular D compiler. As it is I am not sure it can be the unit of packaging. Actually the biggest problem is that the repository appears to have no licence statement so it is not clear what may or may not be done. I believe it may be easiest for the dlang project to separate out rdmd.d and it's test into a separate repository so that it can have a development life all of it's own =E2=80=93 with a licence acceptable to Deb= ian and Fedora. It can then have a Make, CMake, or Meson build added so as to pass the requirements of those distributions (unless Dub has been added to the list of acceptable build tools). Then it may be possible to get the same people who package ldc for Debian and Fedora to package rdmd such that is finds the compilers in some defined order. =20 --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 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
Jan 22 2017
On 1/22/17 7:45 AM, Russel Winder via Digitalmars-d wrote:On Sat, 2017-01-21 at 11:30 -0500, Andrei Alexandrescu via Digitalmars- d wrote: […]It's also the simplest to solve. Should be Boost. Please create a PR copying the Boost license (from e.g. Phobos itself) to the tools repo. Thanks. -- Andreirdmd is a single-file program distributed under a very permissive license. Would you care to repackage it the way you find more appropriate? -- AndreiThe "problem" here is the role of the D Tools repository. Is it solely for DMD, or is it supposed to be something that can be packaged independent of a particular D compiler. As it is I am not sure it can be the unit of packaging. Actually the biggest problem is that the repository appears to have no licence statement so it is not clear what may or may not be done.
Jan 22 2017
On Sunday, 22 January 2017 at 13:24:48 UTC, Andrei Alexandrescu wrote:It's also the simplest to solve. Should be Boost. Please create a PR copying the Boost license (from e.g. Phobos itself) to the tools repo. Thanks. -- AndreiRDMD does have license statement already https://github.com/dlang/tools/blob/master/rdmd.d#L9-L11
Jan 22 2017
On Sun, 2017-01-22 at 13:50 +0000, Dicebot via Digitalmars-d wrote:On Sunday, 22 January 2017 at 13:24:48 UTC, Andrei Alexandrescu=C2=A0 wrote:The repository README.md needs to state what the licence is for the items in the repository if they are all the same or what the licence is for what files so that it is obvious from the repository front page what may and may not be done with the content. Are all files under the Boost licence? --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winderIt's also the simplest to solve. Should be Boost. Please create=C2=A0 a PR copying the Boost license (from e.g. Phobos itself) to the=C2=A0 tools repo. Thanks. -- Andrei=20 RDMD does have license statement already=C2=A0 https://github.com/dlang/tools/blob/master/rdmd.d#L9-L11
Jan 24 2017
On 01/24/2017 10:07 AM, Russel Winder via Digitalmars-d wrote:Are all files under the Boost licence?Affirmative.
Jan 24 2017
On Sunday, 22 January 2017 at 12:45:26 UTC, Russel Winder wrote:The "problem" here is the role of the D Tools repository. Is it solely for DMD, or is it supposed to be something that can be packaged independent of a particular D compiler. As it is I am not sure it can be the unit of packaging.Some time ago I have been packaging tools from that repo build with LDC in Arch Linux, it is trivially doable (see https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/dtools#n26).
Jan 22 2017
On Sun, 2017-01-22 at 13:53 +0000, Dicebot via Digitalmars-d wrote:On Sunday, 22 January 2017 at 12:45:26 UTC, Russel Winder wrote:Perhaps we can convince the people packaging LDC for Debian and Fedora to do the equivalent for those distributions? --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winderThe "problem" here is the role of the D Tools repository. Is it=C2=A0 solely for DMD, or is it supposed to be something that can be=C2=A0 packaged independent of a particular D compiler. As it is I am=C2=A0 not sure it can be the unit of packaging.=20 Some time ago I have been packaging tools from that repo build=C2=A0 with LDC in Arch Linux, it is trivially doable (see=C2=A0 https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD? h=3Dpackages/dtools#n26).
Jan 24 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.
Jan 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.
Jan 20 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 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.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.
Jan 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.
Jan 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.
Jan 20 2017
On Friday, 20 January 2017 at 03:59:12 UTC, 岩倉 澪 wrote:Is anyone else using D for scripting?Yes!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. 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.No comments on rdmd, but have you tried using dub instead of rdmd for scripts. Makes it easier if you have dependencies on code.dlang.org modules. You can embed the dub.sdl in the header of your script.
Jan 22 2017