diff --git a/scripts/ybcon b/scripts/ybcon index af44eb8..73f7974 100755 --- a/scripts/ybcon +++ b/scripts/ybcon @@ -23,11 +23,10 @@ usage() { usageExit() { usage false exit 0 -} +}; helpExit() { usage true; exit 0; } args=""; run=false; -skipArgsIteration=false; newArgs() { if [ "$args" = "" ]; then @@ -39,35 +38,33 @@ newArgs() { if [ "$#" != 0 ]; then if [ "$#" = 1 ]; then - if [ "$1" = "--version" ]; then - run=true - args="$1" - skipArgsIteration=true; - fi - fi - if [ "$skipArgsIteration" = false ]; then + case "$1" in + -h | --help ) + helpExit ;; + --version ) + run=true; args="$1" ;; + *.ybcon ) + newArgs "$1"; run=true ;; + * ) + usageExit ;; + esac + else for it in "$@" - do - case "$it" in - -h | --help | --version ) - if [ "$#" = 1 ]; then usageExit; else - usage true; exit 0; - fi ;; - -p | --printresult | --target=* ) - if test "${args#*$it}" = "$args"; then - if [ "$#" = 1 ]; then usage false; exit 0; else + do + case "$it" in + -p | --printresult | --target=* ) + if test "${args#*$it}" = "$args"; then newArgs "$it" - fi - else - usageExit - fi ;; - *.ybcon ) - newArgs "$it" - run=true ;; - * ) - usageExit ;; - esac - done + else + usageExit + fi ;; + *.ybcon ) + newArgs "$it" + run=true ;; + * ) + usageExit ;; + esac + done fi else usage false @@ -76,7 +73,7 @@ fi runIt() { eval "$1" " $args"; } if [ "$run" = true ]; then - if [ -f $defaultBinLocation ]; then + if [ -f "$defaultBinLocation" ]; then runIt "$defaultBinLocation" elif [ -f ybcon ]; then runIt "./ybcon"