From e24d4ed21b03fb49b862aae23c699ba3b56fda8f Mon Sep 17 00:00:00 2001 From: Christoph Niethammer Date: Mon, 2 May 2016 09:35:39 +0000 Subject: [PATCH] Command line option parsing at the begin of sit. --- sit | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/sit b/sit index a47b7fd..e6c203e 100755 --- a/sit +++ b/sit @@ -29,18 +29,44 @@ function usage() { echo " copy_logs" echo " setperms" echo " all" - exit 0 } # sit class file to be installed -sit_classfile=$1 +sit_classfile="" # sit action to be performed -sit_action=$2 -if [[ -n $sit_action ]] ; then - echo "Performing action: $sit_action" -else - sit_action="all" -fi +sit_action="all" + +while [ $1 != "" ] ; do + case $1 in + "sitinfo") + sit_sitinfo + exit 0 + ;; + "all"| \ + "unpack"| \ + "prepare"| \ + "configure"| \ + "build"| \ + "pretest"| \ + "install"| \ + "posttest"| \ + "postinst"| \ + "copy_logs"| \ + "setperms") + sit_action=$1 + ;; + "-*h"|"--help"|"help"|"usage") + usage $@ + exit 0 + ;; + *) + sit_classfile=$1 + ;; + esac + shift +done +echo "Actions to perform: $sit_action" +echo "Sit class file(s): $sit_classfile" # Reading in user configuration file if it exists if [[ -e $SIT_USER_CONFIG_FILE ]] ; then