Skip to content

Instantly share code, notes, and snippets.

@DrSnowbird
Last active September 8, 2018 19:00
Show Gist options
  • Save DrSnowbird/829c15af3caff08b4177f2997e24e429 to your computer and use it in GitHub Desktop.
Save DrSnowbird/829c15af3caff08b4177f2997e24e429 to your computer and use it in GitHub Desktop.
#!/bin/bash
# ------------------------------------
# maintainer: DrSnowbird@openkbs.org
# license: Apache License Version 2.0
# ------------------------------------
ERROR_NO_ARGS_PROVIDED=99
ERROR_ERROR_ARGS_PROVIDED=98
SHORT="hdO:"
LONG="help,debug,output:"
PARSED=`getopt --options ${SHORT} --longoptions ${LONG} --name "$0" -- "$@"`
if [[ $? != 0 ]]; then
exit ${ERROR_ERROR_ARGS_PROVIDED}
fi
eval set -- "${PARSED}"
while true
do
case "${1}" in
-h)
usage
exit
;;
--help)
usage
exit
;;
-d)
debugFlag=1
echo "debugFlag=$debugFlag (ON)"
shift
;;
--debug)
debugFlag=1
echo "debugFlag=$debugFlag (ON)"
shift 1
;;
-O)
OUTPUT_FILE=${2}
echo "OUTPUT_FILE=$OUTPUT_FILE"
shift 2
;;
--output)
OUTPUT_FILE=${2}
echo "OUTPUT_FILE=$OUTPUT_FILE"
shift 2
;;
--)
shift
break
;;
*)
echo "*****: input args error"
echo "$ORIG_ARGS"
exit 3
;;
esac
done
echo "ORIGINAL INPUT >>>>>>>>>>:"
echo "${ORIG_ARGS}"
echo "-------------"
#### ------------------------------------------------------------------------------------------------------------
#### ---- MAIN: ----
#### ------------------------------------------------------------------------------------------------------------
echo "..... Start your main here .............."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment