Loadables in bash are exactly like builtins, but you enable or disable at runtime. They're shared libraries whose main interface is receiving the WORD_LIST
, which is basically the last command.
For this loadable, I want to provide nice data structures directly to bash.
Vedis is an embeddable self-contained library with commands and data structures from Redis, but without the networking.
For now, I'm just using vedis's command execution. But it would be nicer to have all this stuff work nicely with declare
and other bash stuff.
- build it
you'll probably need the bash-builtins
package from apt or whatever.
$ gcc -I /usr/include/bash/builtins -I /usr/include/bash/include -I /usr/include/bash -I /usr/lib/bash \
-shared -fPIC -o vedis.so vedis_loadable.c vedis.c
- load the feature
$ enable -f ./vedis.so vedis
loaded vedis!
- use it (for now) via the
vedis
bash command, which is now a builtin
$ vedis
vedis> SET foo 42
true
$ vedis
vedis> GET foo
42
note that the values here are in memory for the current bash process itself.
hopefully I can figure out how to make these values interop with normal shell and bash operations.
for now, here's a hash, which bash absolutely sucks at.
$ vedis
vedis> HSET config path "/usr/local/etc"
true
$ vedis
vedis> HKEYS config
1) path
$ vedis
vedis> HGET config path
/usr/local/etc