On Thu, 2019-07-25 at 10:14 +0200, Ulrich Mueller wrote:
> > > > > > On Thu, 25 Jul 2019, Michał Górny wrote:
> > -   local defgroup=${egroups_arr[0]}
> > +   local g groups=( "${egroups_arr[0]}" )
> >     # sort supplementary groups to make comparison possible
> > -   readarray -t exgroups_arr < <(printf '%s\n' "${egroups_arr[@]:1}" | 
> > sort)
> > -   local exgroups=${exgroups_arr[*]}
> > -   echo "${defgroup}${exgroups:+,${exgroups// /,}}"
> > +   while read -r g; do
> > +           [[ -n ${g} ]] && groups+=( "${g}" )
> > +   done < <(printf '%s\n' "${egroups_arr[@]:1}" | sort)
> > +   groups=${groups[*]}
> > +   echo "${groups// /,}"
> >  }
>  
> Why don't you make groups a scalar variable (i.e., a comma separated
> list) from the very beginning, if you're converting to it later anyway?
> 
>       local g groups=${egroups_arr[0]}
>       # sort supplementary groups to make comparison possible
>       while read -r g; do
>               [[ -n ${g} ]] && groups+=",${g}"
>       done < <(printf '%s\n' "${egroups_arr[@]:1}" | sort)
>       echo "${groups}"

Indeed.  Will do.

-- 
Best regards,
Michał Górny

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to