From 72a74fcb5a6a442f93ff0e00594e4e60d5dad416 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 14 Mar 2020 13:31:47 +0100 Subject: [PATCH] build.sh: fixing getopts. --- build.sh | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/build.sh b/build.sh index 27c9fdd..000f124 100755 --- a/build.sh +++ b/build.sh @@ -4,11 +4,11 @@ mkdir build 2> /dev/null pushd build > /dev/null function usage() { - echo "Usage: ${0##*/} [ -h ] [ -t Debug|Release|RelWithDebInfo|MinSizeRel ] [ --disable-threads ] [ --force-ansi ]" + echo "Usage: ${0##*/} [ -h|--help ] [ -t|--type Debug|Release|RelWithDebInfo|MinSizeRel ] [ --disable-threads ] [ --force-ansi ]" exit 1 } -options=$(getopt -n "${0##*/}" -o lht: --long disable-threads --long force-ansi -- "$@") +options=$(getopt -n "${0##*/}" -o "lht:" -l "help,type:,disable-threads,force-ansi" -- "$@") [ $? -eq 0 ] || usage @@ -18,26 +18,26 @@ ONLY_CONFIG=0 ARGS="" while true; do - case "${1}" in - -t) - shift - [[ ! "$1" =~ ^(Debug|Release|RelWithDebInfo|MinSizeRel)$ ]] && { - echo "Incorrect type '$1' provided" - usage - } - ARGS="${ARGS} -DCMAKE_BUILD_TYPE=${1}" - ;; - --disable-threads) - ARGS="${ARGS} -DUSE_THREADS=OFF" ;; - --force-ansi) - ARGS="${ARGS} -DFORCE_ANSI=ON" ;; - -l) - ARGS="${ARGS} -LH" - ONLY_CONFIG=1 ;; - -h) usage ;; - --) shift - break - ;; + case $1 in + -t|--type) + shift + [[ ! "$1" =~ ^(Debug|Release|RelWithDebInfo|MinSizeRel)$ ]] && { + echo "Incorrect type '$1' provided" + usage + } + ARGS="${ARGS} -DCMAKE_BUILD_TYPE=${1}" + ;; + --disable-threads) + ARGS="${ARGS} -DUSE_THREADS=OFF" ;; + --force-ansi) + ARGS="${ARGS} -DFORCE_ANSI=ON" ;; + -l) + ARGS="${ARGS} -LH" + ONLY_CONFIG=1 ;; + -h|--help) usage ;; + --) shift + break + ;; esac shift done