On Friday, 17 August 2012 at 12:53:50 UTC, Graham Fawcett wrote:
On Tuesday, 14 August 2012 at 04:09:22 UTC, Nick Sabalausky
wrote:
On Mon, 13 Aug 2012 17:36:13 +0200
"jerro" <a...@a.com> wrote:
> I probably should make it so it automatically wraps the
> code in a main function for even easier and more script
> like usage.
Rdmd already has this functionality with the --eval flag. You
are supposed to pass the code as a command line parameter,
but you can use it with files like this:
cat - test.d <<< "--eval=" | xargs -0 rdmd
I've only tried this on Linux.
As a person who's still only half-way a Linux guy, I have to
ask: What
the hell is going on in that command?
I understand bits and pieces of it, but my mind's having a
hard time
parsing it. Can any of you unix gurus help me out?
Run the "cat" program, which prints two file contents: the
first file is stdin (denoted by "-"), which contains the text
"--eval=", via the <<< redirector. Cat then prints the contents
of test.d. All of this is piped in to "xargs", which calls dmd
along with the command line arguments consisting of the piped
input.
It's overly complicated. Try this instead:
rdmd --eval="$(cat test.d)"
Best,
Graham
I meant to add, the point of this appears to be that you can
execute a "toplevel expression." So test.d should contain bare
statements, e.g.
import std.stdio; writeln("hi");
rather than
void main() { import std.stdio; writeln("hi"); }