BILL built-ins

Author: Adrián Pérez <aperez@igalia.com>
Copyright: 2008-2009 Igalia S.L.
License:GPL3

Abstract

Provides functions of common usage in shell code. This module is always imported by the Bill interpreter at startup.

Contents

warn

warn message

Prints a message to the standard error stream.

die

die [ message ]

Exits running process with a non-zero status, optionally printing an error message before exiting.

need

need tool1 [ tool2 [ ... [ toolN ] ] ]

Checks whether a list of commands are available on the system and can be accessed by means of the current $PATH setting. If one of the dependencies is not met, return status will be non-zero. If you want to know exactly which tool was not found then check the tools one at a time:

need openssl || die "openssl not found"
need convert || die "ImageMagick is not installed"

use

use module

Loads one module from the library search path, which is itself taken from the $BILLPATH environment variable. If a module is not found, execution will be aborted and an informative message will be printed to standard error.

The function will search for a function named the same as the module name with slashes changed to underscores, prefixed with __bill_module__. If the function is found, it will be executed instead of sourcing the module from disk.

On successful module load the module name will be appended to the bill_loaded_modules array, and when trying to load the module afterwards will do nothing.

main

main

Checks whether a module is running as a standalone script and runs the supplied function with a set of arguments. This allows modules both being imported and for acting as a script. For example.

foo () {
    echo "I am foo"
}

main foo