[PATCH build 6/6] Use getopt(1) to parse cmdline.

Peter Hutterer peter.hutterer at who-t.net
Sat Sep 11 03:54:19 PDT 2010


On Wed, Sep 08, 2010 at 10:37:26AM -0400, Trevor Woerner wrote:
> From: Trevor Woerner <twoerner at gmail.com>
> 
> Switch to using a standard command-line parsing tool: getopt.
> Hopefully this will help catch discrepancies between the usage
> screen and the options that are accepted and ensure required
> arguments are accounted for.
> 
> Signed-off-by: Trevor Woerner <twoerner at gmail.com>
> ---
>  build.sh |   18 +++++++++++++++---
>  1 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/build.sh b/build.sh
> index 9e74c28..e766fa5 100755
> --- a/build.sh
> +++ b/build.sh
> @@ -762,8 +762,14 @@ DIR_CONFIG="."
>  LIB_ONLY=0
>  
>  # Process command line args
> -while test $# != 0; do
> -    case $1 in
> +CMDLINE=`getopt -o abcdDf:ghlno:pr:s:L --long clone,autoresume:,check,help -n $0 -- "$@"`
> +if test $? != 0; then
> +    echo "getopt invocation error"
> +    exit 1
> +fi
> +eval set -- "$CMDLINE"
> +while true; do
> +    case "$1" in
>      -a)
>  	NOAUTOGEN=1
>  	;;
> @@ -829,13 +835,19 @@ while test $# != 0; do
>      -L)
>  	LISTONLY=1
>  	;;
> +    --)
> +	shift
> +	break
> +	;;
>      *)
> -	PREFIX=$1
> +	echo "internal getopt error!"
> +	exit 1
>  	;;
>      esac
>  
>      shift
>  done
> +PREFIX=$*
>  
>  if test x"${PREFIX}" = x && test -z "$LISTONLY"; then
>      usage
> -- 
> 1.7.1
> 

Acked-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
  Peter


More information about the xorg-devel mailing list