Skip to content

Instantly share code, notes, and snippets.

@echohn
Created October 8, 2015 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save echohn/073f6d68febdd4fcf587 to your computer and use it in GitHub Desktop.
Save echohn/073f6d68febdd4fcf587 to your computer and use it in GitHub Desktop.
bash getopt
ARGS=`getopt -o dph -l help,debug,jdk-update,jdk-retreat,tomcat-update,tomcat-retreat,apache-update,apache-retreat,tomcat-conn-update -- "$@"`
[ $? -ne 0 ] && usage
eval set -- ${ARGS}
while [ true ]
do
case $1 in
--debug)
IS_DEBUG="true"
debug=1
;;
-h|--help)
IS_HELP="true"
;;
--jdk-update|--jdk-retreat|--tomcat-update|--tomcat-retreat|--apache-update|--apache-retreat|--tomcat-conn-update)
IS_OPERATION="$1"
;;
#-c|--change)
# IS_OPERATION="change"
#CONFIG_FILE="$2"
#shift
# ;;
--)
#shift
break
;;
*)
usage
;;
esac
shift
done
[ "${IS_HELP}" == "true" ] && usage
[ "${IS_DEBUG}" == "true" ] && set -x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment