From c087d8b2f0c73ea6c3b721099732d98ccef74f7c Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Fri, 26 Mar 2021 12:55:33 +0100 Subject: [PATCH] Shorten the ybcon shell command script. --- scripts/ybcon | 57 ++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 30 deletions(-) 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"