libbash is a tool that enables bash dynamic-like shared libraries.
To achieve its goal, it uses some kind of "dynamic loader" that you call to load desired bash library (actually just to source bash code).
Suppose you've written some great bash script. You've surelly splitted it to some functions that do parameter parsing, etc... Now you want to reuse that code in some other script. What do you do? The general solution is to cut out that reusable code from your first script, put it in separate file, and then source it from both scripts.
Well, this may work fine, but what if your two scripts are completely unrelated and, in fact, belong to completely different projects, that do not share any common files. So you need to keep a copy of that reusable code in each project, and ... down we go...
The libbash was born to address the above problem. It may be seen as script organizer. It holds "reusable code" in centralized place (typically /lib/bash/). Then you can use it to check what libraries are available, what functions they provide and actually source desired code.
#> ldbash -l Libraries: getopts hashstash
man getopts for example. When you've decided to go with getopts, you run
#> ldbash -e getopts
External:
getopts:
getopt_long
getopts library provides getopt_long function (use man to find out what it does and how to use it).
From now on can start writing your script that uses getopt_long. The question you ask now is: "How do I load that function to my script?" The aswer is very simple. Consider:
#> ldbash -L getopts source /usr/lib/bash/getopts.sh; source /usr/lib/bash/hashstash.sh;
eval `ldbash -L getopts`
getopts.sh and some mysterous hashstash.sh. The reason is that getopts reported that it requires hashstash and libbash tracked that request and fulfilled it.ldbash [-h | --help] ldbash [-l | --list] ldbash [-L | --load lib,[lib] ...] ldbash [-U | --unload lib,[lib] ...] ldbash [-e | --externlist lib,[lib] ...]ldbash [--externlist-all]ldbash [--i | --internlist lib,[lib] ...]ldbash [--internlist-all]
libbash was tested in bash 3.x. It may also work with 2.0x versions, but this is 'not supported' :)
Although you will need Doxygen to generate html documentation (the one you are reading at this moment).
1.5.5