From 0049899c86fd059fdff60fd2622446053a2cfc99 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Thu, 25 Feb 2021 18:51:03 +0100 Subject: [PATCH] Show the command's usage when no arguments are provided. --- scripts/ybcon.sh | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/scripts/ybcon.sh b/scripts/ybcon.sh index 2071eb2..ecba79d 100755 --- a/scripts/ybcon.sh +++ b/scripts/ybcon.sh @@ -24,24 +24,28 @@ newArgs() { fi } -for it in "$@" -do - case "$it" in - -h | --help ) - echo "Usage:" - usage - exit 0 ;; - -p | -printresult ) - newArgs "$it" - shift ;; - *.ybcon ) - newArgs "$it" - run=true - break ;; - * ) - usage ;; - esac -done +if [ "$#" != 0 ]; then + for it in "$@" + do + case "$it" in + -h | --help ) + echo "Usage:" + usage + exit 0 ;; + -p | -printresult ) + newArgs "$it" + shift ;; + *.ybcon ) + newArgs "$it" + run=true + break ;; + * ) + usage ;; + esac + done +else + usage +fi runIt() { eval "$1" " $args"; }