From 58d16c1db9650e0da6f7c6ec5cc6fe8cc944f1ab Mon Sep 17 00:00:00 2001 From: Markus Teich Date: Sun, 17 Jan 2016 14:36:40 +0100 Subject: gello-build: streamline flag parsing Change-Id: I9633d1dde3cf881e12327ae020f7f7bf29377cfb --- gello_build.sh | 56 +++++++++++++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/gello_build.sh b/gello_build.sh index ebe13fd..82922b6 100755 --- a/gello_build.sh +++ b/gello_build.sh @@ -145,38 +145,28 @@ function compile() { ## # Check Flags # -function checkflags() { - if [ "$1" == "--verbose" ] || [ "$2" == "--verbose" ] || - [ "$3" == "--verbose" ] || [ "$4" == "--verbose" ] || - [ "$5" == "--verbose" ]; then - VERBOSE=true - fi - - if [ "$1" == "--fast" ] || [ "$2" == "--fast" ] || - [ "$3" == "--fast" ] || [ "$4" == "--fast" ] || - [ "$5" == "--fast" ]; then - NOSYNC=true - FAST=true - fi - - if [ "$1" == "--no-sync" ] || [ "$2" == "--no-sync" ] || - [ "$3" == "--no-sync" ] || [ "$4" == "--no-sync" ] || - [ "$5" == "--no-sync" ]; then - NOSYNC=true - fi - - if [ "$1" == "--push" ] || [ "$2" == "--push" ] || - [ "$3" == "--push" ] || [ "$4" == "--push" ] || - [ "$5" == "--push" ]; then - PUSH=true - fi - - if [ "$1" == "--clean" ] || [ "$2" == "--clean" ] || - [ "$3" == "--clean" ] || [ "$4" == "--clean" ] || - [ "$5" == "--clean" ]; then - CLEAN=true - fi - +function parseflags() { + for flag in "$@" + do + case "$flag" in + --verbose) + VERBOSE=true + ;; + --fast) + NOSYNC=true + FAST=true + ;; + --no-sync) + NOSYNC=true + ;; + --push) + PUSH=true + ;; + --clean) + CLEAN=true + ;; + esac + done } @@ -219,7 +209,7 @@ elif [ "$1" == "--help" ]; then helpgello && exit 0 fi -checkflags $1 $2 $3 $4 $5 +parseflags "$@" sync && setup && compile -- cgit v1.2.3