This is the home page of MBFL, a collection of libraries for the GNU Bash shell. 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.


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


Copyright (c) 2003-2005, 2009, 2012 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.


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:=$(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.


MBFL should work with all the revisions of Bash from 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.


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


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.

Related stuff

Tom Andrews has written a Bash functions library to send email, aimed at mailing lists processing. It is called lib_MTA and it can be downloaded here.