Primary menu

Post navigation

libinclude released!

If you are working frequently on the command shell of POSIX systems, you may also make use of shell scripts in a more sophisticated manner than just executing a pile of commands. At this point I came to the conclusion, that one can save up a lot of stupid copy & paste work by transferring often used functions to a separate file which can be simply included if necessary.

I use shell scripts extensively in order to create, execute and finally analyse computer simulations in a highly automatize way. Here I can often re-use functions, like those which are extracting data from output files, e.g.. To make the usage of those libraries more comfortable, Sebastian and me have developed libinclude.

Basics

To put it simply, libinclude is a shell library to import other shell scripts as libraries.

As a library we consider a simple shell script containing function and/or variable definitions. Libinclude offers you the possibility to use those kind of libraries in a comfortable manner. The usage is very close to the syntax of python’s import statement. Functions (FUNC) and variables (VAR) in a library (MYLIB) can be simply included, but also imported in their own namespace (MYLIB_VAR, MYLIB_FUNC). It also provides the import MYLIB as ALIAS and the from MYLIB import FUNC statement, like in python. More about general usage…

Features

To ensure the usability of the libraries across different OS and/or software configurations, libinclude provides some features to be utilized in the libraries. One can define dependencies with 3ed party programs, which will be checked while importing and returns a meaningful error message if not met. To adopt the library to different environments, conditional comments provide the possibility to include code blocks depending on defined conditions. It is also possible to run code on file inclusion by define a preprocessing block. More about library features…