bash 'header' files

# So you want to load a set of library functions but not
# constantly reload if they are already loaded?
#
# For example:
 
if [[ ! -n $__UTILS_LOADED__ ]]
then

function print { local line="$@"; printf "%s\n" "$line"; }

function map { local l; while read -r l; do $1 $l; done; }

print '*** UTILS LOADED ***'
__UTILS_LOADED__=TRUE
fi


# Now you can put...
source /some/path/to/lib/utils.sh
# ...where ever you want.

Comments

Popular posts from this blog

oche, lik echo but a bit easier to use.

Bithon: Run Python Interactively Inside Bash

Parsing Columns From Files WITHOUT awk