| #!/bin/bash | 
 |  | 
 | # Template to start a simple bash program.  This is designed only for the | 
 | # simplest of programs where all program paramters are positional, there is no | 
 | # help text, etc. | 
 |  | 
 | # Description of argument(s): | 
 | # parm1            Bla, bla, bla (e.g. "example data"). | 
 |  | 
 |  | 
 | ############################################################################### | 
 | function get_parms { | 
 |  | 
 |   # Get program parms. | 
 |  | 
 |   parm1="${1}" ; shift | 
 |  | 
 |   return 0 | 
 |  | 
 | } | 
 | ############################################################################### | 
 |  | 
 |  | 
 | ############################################################################### | 
 | function validate_parms { | 
 |  | 
 |   # Validate program parameters. | 
 |  | 
 |   # Your validation code here. | 
 |  | 
 |   if [ -z "${parm1}" ] ; then | 
 |     echo "**ERROR** You must provide..." >&2 | 
 |     return 1 | 
 |   fi | 
 |  | 
 |   return 0 | 
 |  | 
 | } | 
 | ############################################################################### | 
 |  | 
 |  | 
 | ############################################################################### | 
 | function mainf { | 
 |  | 
 |   # We create a mainf for a couple of reasons: | 
 |   # The coding rules in a template are slightly different than for the true | 
 |   # mainline.  We wish to eliminate those inconsistencies.  Examples: | 
 |   # - The "local" builtin is allowed in functions but not in the mainline. | 
 |   # - It is good practice to have functions return 1 rather than exit 1. | 
 |   #   return is not valid in the mainline.  Again, we don't want to have to | 
 |   #   care when we code things about whether we are in the mainline or a | 
 |   #   function. | 
 |  | 
 |   get_parms "$@" || return 1 | 
 |  | 
 |   validate_parms || return 1 | 
 |  | 
 |   # Your code here... | 
 |  | 
 |   return 0 | 
 |  | 
 | } | 
 | ############################################################################### | 
 |  | 
 |  | 
 | ############################################################################### | 
 | # Main | 
 |  | 
 |   mainf "${@}" | 
 |   rc="${?}" | 
 |   exit "${rc}" | 
 |  | 
 | ############################################################################### |