I have this in my kakrc
:
def tst -params .. %{
echo -debug %sh{#!perl -wn
print if /:root:/
}
}
tst /etc/passwd
which produces the expected line in *debug*
How?
Again, how?
The script parses the command line
- if it starts with a shebang, it runs the body below the shebang with the specified shebang, passing on arguments. Unlike a shebang, binaries can be in
$PATH
, not just absolute names. - if not, it
eval
’s the body (nofork / exec
), again setting up"$@"
properly
What next
I see a lot of possibilities; for example, I could have a server that keeps pre-forked interpreters (perl
, lua
, whatever) in stdin mode; when fakesh
tells the server to run something, it simply sends of a source
command to the appropriate interpreter (and forks a new one).
Perhaps this has been done already, I haven’t reviewed everything in the ecosystem. Anyway, hope this is helpful.