Up: bash  


Marco’s Bash Functions Library

Abstract

This is the home page of mbfl, a collection of libraries for the gnu Bash shell. It requires Bash at least version 4.3. It is an attempt to make gnu Bash a viable solution for medium sized scripts. A set of modules implementing common operations and a script template are offered by this package and the author has used them with success in implementing non-small scripts.

Download

The latest revision is available from the GitHub project page, while stable and beta releases can be downloaded from the download page. The documentation for the latest stable release is online.

License

Copyright © 2003-2005, 2009, 2012, 2018 Marco Maggi.

This is free software; you can redistribute it and/or modify it under the terms of the gnu Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the gnu Lesser General Public License for more details.

Overview

The philosophy of mbfl is to do the work as much as possible without external commands. For example: string manipulation is done using the special variable substitution provided by Bash, and no use is done of utilities like sed and grep.

The library is better used starting from the template script (examples/template.sh in the distribution). This is because with mbfl some choices have been made to reduce the application dependent part of the script to the smallest dimension; if we follow another scheme, mbfl modules may be inadequate. This is especially true for the options parsing module.

The easiest way to use the library is to include at run time the library file libmbfl.sh in the script. To do it, we install the package on the system and use this code in the scripts:

source "${MBFL_LIBRARY:=$(type -p mbfl-config &>/dev/null && mbfl-config)}"

the full pathname of the library is acquired from the environment variable MBFL_LIBRARY; if this variable is not set: the script mbfl-config is invoked with no arguments to acquire the pathname. mbfl-config is installed by the package in the ‘$(bindir)’ directory, which we must include in the PATH environment variable.

As a usage example, the mbfl distribution includes a script (sendmail-mbfl.sh) that acts as a mail client: it reads fully composed email messages and delivers them to smtp servers. The session can be plain or encrypted with TLS; for the TLS layer, it can use both the openssl program that comes with OpenSSL and the gnutls-cli program that comes with gnu TLS. Also available is an interface for gnu Emacs (sendmail-smtp.el), which can be used to send email with the script through the message-send-mail-function interface (offered by the message.el library).

A full discussion of the sendmail-mbfl.sh script implementation is in the mbfl documentation.

Prerequisites

mbfl should work with all the revisions of Bash from 4.3 onwards.

The gnu m4 preprocessor must be installed because mbfl provides a script preprocessor built on top of it.

The mbfl installation infrastructure supports only gnu systems. This means Unix like systems in which the following common tools and packages are installed: gnu Bash, gnu Make, gnu Coreutils, gnu Find, gnu tar, Gzip, Bzip2.

Bugs

If you feel the need to report a bug you can use the issue tracker at GitHub.

Credits

The stuff was written by Marco Maggi. If this package exists it’s because of the great gnu software tools that he uses all the time.


Up: bash