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 <[email protected]>

TIL {:?}, nice.

Reviewed-by: Daniel Vetter <[email protected]>

> ---
>  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
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dim-tools

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dim-tools mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dim-tools

Reply via email to