Kipibenkipod view of the world

Defensive BASH Programming

Here is my Katas for creating BASH programs that work. Nothing is new here, but
from my experience pepole like to abuse BASH, forget computer science and create
a Big ball of mud from their programs.
Here I provide methods to defend your programs from braking, and keep the code
tidy and clean.

usage(){ cat <<- EOF usage: $PROGNAME options Program deletes files from filesystems to release space. It gets config file that define fileystem paths to work on, and whitelist rules to keep certain files. OPTIONS: -c --config configuration file containing the rules. use --help-config to see the syntax. -n --pretend do not really delete, just how what you are going to do. -t --test run unit test to check the program -v --verbose Verbose. You can specify more then one -v to have more verbose -x --debug debug -h --help show this help --help-config configuration help Examples: Run all tests: $PROGNAME --test all Run specific test: $PROGNAME --test test_string.sh Run: $PROGNAME --config /path/to/config/$PROGNAME.conf Just show what you are going to do: $PROGNAME -vn -c /path/to/config/$PROGNAME.conf EOF}

Pay attention that there should be real tab ‘\t’ in the start of the line for each
line.
In vim you can use this replace command if your tab is 4 spaces: