Bob Hepple - 2013-04-22

A wrapper for getopt(1) which simulates argp(3) for bash. Normally other scripts pipe their option descriptions in here for automatic help and man mpage production and for generating the code for getopt(1). Requires bash-3+. See also argp(1) which is a binary (and much faster) version of this.

See http://sourceforge.net/projects/process-getopt
See http://process-getopt.sourceforge.net
See http://bhepple.freeshell.org/oddmuse/wiki.cgi/process-getopt

It buys you:

o all the goodness of getopt
o define options in one central place together with descriptions.
o fewer 'magic' and duplicated values in your code
o better consistency between the getopt calling parameters, the case
statement processing the user's options and the help/man pages
o less spaghetti in your own code
o easier to maintain
o help-page and man-page printing - all from the same data sources
o checking of option consistency at runtime
o range checking of option values at runtime
o pretty easy to use
o portable to OS's without long option support - the help page
adapts too

 

Last edit: Bob Hepple 2013-04-22