libbash
|
libbash library is basicly just script. Script that define functions that become available when you source it.
A bash shared library that can be loaded using ldbash
must answer 3 requirments:
#EXPORT=
. That line will contain (after the '='
) a list of fuctions that the library exports. I.e. all the function that will be usable after loading that library will be listed in that line.#REQUIRE=
. That line will contain (after the '='
) a list of bash functions that are required for our library. I.e. every bash function that is in use in our bash library, and should be defined by another library, must be listed there.ldbashconfig
man page ).Be aware, that your library will be actually sourced. So, basicly, It should contain (i.e define) only functions.
#EXPORT=
) shoud begin with: __<library_name>_ For example, internal function myfoosort of hashstash library should be named as __hashstash_myfoosortThis helps to avoid conflicts in global namespace when using libraries that come from different vendors.
libbash is splitted in two utilites: - \c ldbash: library loader - \c ldbashconfig: checks out available libraries, resolves cross-library dependencies and builds cache file. As number of libraries grows, it may take considerable amount of time to scan them all and resolve dependencies. That is why this process is done by separate utility - \c ldbashconfig. Afterwards, at runtime, \c ldbash reads cache file and determinies which libraries it needs to load in order to satisfy dependencies for requested library. Install steps: - name your library \c \<something\>\c .sh - put it in \c $LIBBASH_PREFIX/lib/bash (default is \c /usr/lib/bash). - run \c ldbashconfig