Shorten the ybcon shell command script.
This commit is contained in:
parent
c933c7e86e
commit
c087d8b2f0
@ -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,35 +38,33 @@ 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 )
|
-p | --printresult | --target=* )
|
||||||
if [ "$#" = 1 ]; then usageExit; else
|
if test "${args#*$it}" = "$args"; then
|
||||||
usage true; exit 0;
|
|
||||||
fi ;;
|
|
||||||
-p | --printresult | --target=* )
|
|
||||||
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 ;;
|
*.ybcon )
|
||||||
*.ybcon )
|
newArgs "$it"
|
||||||
newArgs "$it"
|
run=true ;;
|
||||||
run=true ;;
|
* )
|
||||||
* )
|
usageExit ;;
|
||||||
usageExit ;;
|
esac
|
||||||
esac
|
done
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
usage false
|
usage false
|
||||||
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user