[PATCH 4/9] dim: use ${1:?$usage} for create-workdir argument checking

Daniel Vetter daniel at ffwll.ch
Tue Apr 3 08:46:49 UTC 2018


On Thu, Mar 29, 2018 at 11:45:56AM +0300, Jani Nikula wrote:
> The benefit of ${1:?$usage} is two-fold. First, it allows enabling of
> set -u without errors about unbound variable references. Second, it
> provides a uniform error message about missing arguments.
> 
> Signed-off-by: Jani Nikula <jani.nikula at intel.com>

TIL {:?}, nice.

Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

> ---
>  dim | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/dim b/dim
> index 2496703aac7f..b41beca7301b 100755
> --- a/dim
> +++ b/dim
> @@ -1602,19 +1602,16 @@ function prep_pull_mail
>  
>  function dim_create_workdir
>  {
> -	local branches
> +	local branch branches
>  
> -	cd $DIM_PREFIX
> +	branches=${1:?$usage}
>  
> -	if [[ "x$1" = "x" ]]; then
> -		echo "usage: $dim $subcommand branch|all"
> -		exit 1
> -	elif [[ "$1" = "all" ]] ; then
> +	if [[ "$branches" = "all" ]]; then
>  		branches=$dim_branches
> -	else
> -		branches=$1
>  	fi
>  
> +	cd $DIM_PREFIX
> +
>  	for branch in $branches ; do
>  		if [[ -d $branch ]] ; then
>  			continue;
> -- 
> 2.11.0
> 
> _______________________________________________
> dim-tools mailing list
> dim-tools at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dim-tools

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dim-tools mailing list