Writing some built-in functions for Bash, possible?

Andrea Fontana nospam at example.com
Wed Oct 18 08:22:09 UTC 2017


On Wednesday, 18 October 2017 at 03:48:01 UTC, Ky-Anh Huynh wrote:
> Hi,
>
> I'm using Bash heavily in my systems. Things become slow and 
> slow when I have tons of scripts :) And sometimes it's not easy 
> to manipulate data.
>
> You may have heard of recutils [1] which has a C extension to 
> be loaded by Bash. Is it possible to write similar things in D, 
> for Bash? I am not good at C; it's great if I explore this 
> field:)
>
> Some examples in C are in [2].
>
> My experience: Dlang has `pipe` support however the syntax is 
> not as clean as Bash :) Most of the times I see short (<1k loc) 
> Bash scripts are easy to maintain than Ruby (and now D things) 
> scripts.
>
> Thanks for your reading.
>
> [1]: https://news.ycombinator.com/item?id=15302035
> [2]: 
> http://git.savannah.gnu.org/cgit/bash.git/tree/examples/loadables/cat.c

You can write your script in D using
#!/usr/local/bin/rdmd
as shebang line.

Or, using dstep, you can convert C headers to D imports, so you 
can compile your own extension in D.

Andrea


More information about the Digitalmars-d-learn mailing list