Archive for May 2012
Probably it will be a good idea not to write every script from a blank page, because the most scripts at the beginning contains the same information. like “what this pease of code does”, “who wrote it and when”, “default options declarations” and etc.
In following template I’ll define the most popular parts that all good scripts should contain. Also I figured out that adding --debug option is a very usefull thing that allows you to deep dive throught the code without extra manipulations.
Simple, clean, usefull:
# Execution frequency:
# Author: Name e-mail DD/MM/YYYY
ARGS=`getopt -o h --long help,debug -- “$@“`
eval set -- “$ARGS“
while true ; do
case “$1” in
-h| --help) usage; exit 0;;
--debug) set -x; shift;;
--) shift ; break ;;
*) echo “Internal error!“; usage; exit 1;;