Shorten the ybcon shell command script.

This commit is contained in:
Username404-59 2021-03-26 12:55:33 +01:00
parent c933c7e86e
commit c087d8b2f0
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1

View File

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