Discussion:
[Help-bash] Writing custom builtins
Samadi van Koten
2018-01-16 15:29:00 UTC
Permalink
Hi,

I'm in the process of trying to write some builtins for Bash. I've
installed the bash-builtins Debian package and used its headers to write
a few simple tests, but my latest experiment is proving rather more
difficult: I'd like to write a builtin that runs other bash commands,
which could be builtins, functions or executables.

Through browsing the source, I've managed to unearth the
"execute_command" function from "execute_cmd.h", but this is not
included in the headers provided by bash-builtins. It's possible I could
declare it in my source file, but I've not tried yet because I'm
struggling to figure out how to create a COMMAND which it needs as an
argument. There is (also not in the bash-builtins headers) a function
which creates a COMMAND from a SIMPLE_COM, which looks a little easier
to create, but it's still not the easiest thing I've seen.

Any advice or examples would be greatly appreciated.

Regards,

Samadi van Koten
Chet Ramey
2018-01-16 16:43:19 UTC
Permalink
Post by Samadi van Koten
Hi,
I'm in the process of trying to write some builtins for Bash. I've
installed the bash-builtins Debian package and used its headers to write a
few simple tests, but my latest experiment is proving rather more
difficult: I'd like to write a builtin that runs other bash commands, which
could be builtins, functions or executables.
The easiest path to where you want to go is parse_and_execute().
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
Loading...