Show the usage only one time in ybcon.sh, in all possible cases.

This commit is contained in:
Username404-59 2021-02-28 13:59:05 +01:00
parent 5c3eb35923
commit ebd42d06b1
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 9 additions and 8 deletions

View File

@ -17,7 +17,11 @@ usage() {
fi fi
} }
pUsed=false usageExit() {
usage false
exit 0
}
args=""; args="";
run=false; run=false;
skipArgsIteration=false; skipArgsIteration=false;
@ -48,21 +52,18 @@ if [ "$#" != 0 ]; then
do do
case "$it" in case "$it" in
-h | --help | --version ) -h | --help | --version )
usage false usageExit ;;
exit 0 ;;
-p | --printresult ) -p | --printresult )
if [ $pUsed = false ]; then if test "${args#*$it}" = "$args"; then
pUsed=true
newArgs "$it" newArgs "$it"
else else
usage false usageExit
exit 0
fi ;; fi ;;
*.ybcon ) *.ybcon )
newArgs "$it" newArgs "$it"
run=true ;; run=true ;;
* ) * )
usage false ;; usageExit ;;
esac esac
done done
fi fi