"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: storing regress test data outside of /tmp
To:
Christian Weisgerber <naddy@mips.inka.de>
Cc:
gameoftrees@openbsd.org
Date:
Sat, 3 Oct 2020 12:19:31 +0200

Download raw body.

Thread
On Fri, Oct 02, 2020 at 10:17:57PM +0200, Christian Weisgerber wrote:
> Christian Weisgerber:
> 
> > > Sure, we can add quotes. Note though that paths with spaces do not
> > > work regardless because getopt(1) does not process such arguments
> > > correctly (see the BUGS section in its man page).
> > 
> > That I can fix.
> 
> getopt(1) is woefully obsolete, let's use getopts:
> 
> rewrite argument parsing with the POSIX getopts shell built-in

Does this patch aim to allow using test root paths with spaces?
Even with quotes added around "$OPTARG" I cannot get tests to run
with GOT_TEST_ROOT="~/got test"

> diff 016859fc51b660d7fc95ca5eff449d62c67f8a7f /home/naddy/got
> blob - d9826710cfeadefeac8b7e325869f980798d41af
> file + regress/cmdline/common.sh
> --- regress/cmdline/common.sh
> +++ regress/cmdline/common.sh
> @@ -200,26 +200,20 @@ test_cleanup()
>  
>  test_parseargs()
>  {
> -	args=`getopt qr: $*`
> -	if [ $? -ne 0 ]; then
> -		echo "Supported options:"
> -		echo "  -q: quiet mode"
> -		echo "  -r PATH: use PATH as test data root directory"
> -		exit 2
> -	fi
> -	set -- $args
> -	while [ $# -ne 0 ]; do
> -		case "$1"
> -		in
> -			-q)
> -			   export GOT_TEST_QUIET=1; shift;;
> -			-r)
> -			   export GOT_TEST_ROOT="$2"; shift; shift;;
> -			--)
> -			   shift; break;;
> +	while getopts qr: flag; do
> +		case $flag in
> +		q)	export GOT_TEST_QUIET=1
> +			;;
> +		r)	export GOT_TEST_ROOT=$OPTARG
> +			;;
> +		?)	echo "Supported options:"
> +			echo "  -q: quiet mode"
> +			echo "  -r PATH: use PATH as test data root directory"
> +			exit 2
> +			;;
>  		esac
>  	done
> -}
> +} >&2
>  
>  run_test()
>  {
> -- 
> Christian "naddy" Weisgerber                          naddy@mips.inka.de
> 
>