Several changes.  Changed the arithmetic operation (()) to a test case to prevent a subshell and the use of math inside shell... which is always risky.  Added a fail_sauce function to print-and-quit for ease of use.  Added exit variables for ease of use.  Fixed a lot of if..else..fi with what I call else-less programming.  People have a (bad) habit of doing this:  if positive test ; then do positive thing ; else alert about negative thing ; fi.  This can be replaced with a much cleaner version:  if negative thing ; alert about negative thing ; fi <continue on with positive thing outside the if construct).  It's wayyyy cleaner to read IMO.  I also switched the big if..elif..elif...elif..fi construct to a case..esac strucutre.  If the if..elif stuff was intention for older versions of bash, sorry.
Several changes.  Changed the arithmetic operation (()) to a test case to prevent a subshell and the use of math inside shell... which is always risky.  Added a fail_sauce function to print-and-quit for ease of use.  Added exit variables for ease of use.  Fixed a lot of if..else..fi with what I call else-less programming.  People have a (bad) habit of doing this:  if positive test ; then do positive thing ; else alert about negative thing ; fi.  This can be replaced with a much cleaner version:  if negative thing ; alert about negative thing ; fi <continue on with positive thing outside the if construct).  It's wayyyy cleaner to read IMO.  I also switched the big if..elif..elif...elif..fi construct to a case..esac strucutre.  If the if..elif stuff was intention for older versions of bash, sorry.

llowder/Zwiebelschaler