From: Fredrik Tolf Date: Thu, 24 Feb 2011 09:36:56 +0000 (+0100) Subject: Improved sztest argument parsing. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=8f1c8d496df088d8c4808b720b127dd95b30e239;p=utils.git Improved sztest argument parsing. --- diff --git a/sztest b/sztest index 2393971..ca7182c 100755 --- a/sztest +++ b/sztest @@ -1,9 +1,8 @@ #!/bin/sh -if [ $# -lt 1 ]; then - echo "usage: sztest [-H SYS-HEADER] [-L LOCAL-HEADER] TYPE [CCFLAGS...]" >&2 - exit 1 -fi +usage() { + echo "usage: sztest [-h] [-H SYS-HEADER] [-L LOCAL-HEADER] TYPE [CCFLAGS...]" +} sheaders= lheaders= @@ -11,6 +10,10 @@ while [ "${1:0:1}" = "-" ]; do opt="$1" shift case "$opt" in + "-h") + usage + exit 0 + ;; "-H") sheaders="$sheaders $1" shift @@ -21,6 +24,10 @@ while [ "${1:0:1}" = "-" ]; do ;; esac done +if [ $# -lt 1 ]; then + usage >&2 + exit 1 +fi type="$1" shift file="$(mktemp /tmp/sztestXXXXXX)"