Easy bash scripting with shflags

One of the most frustrating things about bash scripts is how challenging
it is to create unix style executables. You know, the ones where you can
pass in -h or –help and see the set of options for the program. Up until
now this has been a very manual process in bash, but no longer. Enter
the shflags project from Kate Ward where a bash library takes care of
all the nasty work and producing an elegant way to add option (or
argument) support to your scripts.

shflags is a powerful (and simple) tool for handling command line args
in bash. It works on both Gnu and Bsd systems without any tricky
handling which makes it a unique solution.

Usage

Shflags syntax is easy to understand an use. It comprises three
sections, including shflags, a definition section and an initialization
section.
As in everything with bash, this needs to be written in order, as bash
executes top down.

Including shflags

# source shflags
. ./shflags
or
source /path/to/shflags

The first line is a shortcut to sourcing a file in the same directory
which makes this quite portable.
If the shflags library exists in another place on the drive, but it
needs to be specified and isn’t all that portable.

Defining options

shFlags supports boolean, float, integer and string. Since shell doesn’t
natively support float, they are technically strings handled like floats
and as such regular string comparison operators ( =, != ) should be
used.