1 |
On Thu, 2019-07-25 at 10:14 +0200, Ulrich Mueller wrote: |
2 |
> > > > > > On Thu, 25 Jul 2019, Michał Górny wrote: |
3 |
> > - local defgroup=${egroups_arr[0]} |
4 |
> > + local g groups=( "${egroups_arr[0]}" ) |
5 |
> > # sort supplementary groups to make comparison possible |
6 |
> > - readarray -t exgroups_arr < <(printf '%s\n' "${egroups_arr[@]:1}" | sort) |
7 |
> > - local exgroups=${exgroups_arr[*]} |
8 |
> > - echo "${defgroup}${exgroups:+,${exgroups// /,}}" |
9 |
> > + while read -r g; do |
10 |
> > + [[ -n ${g} ]] && groups+=( "${g}" ) |
11 |
> > + done < <(printf '%s\n' "${egroups_arr[@]:1}" | sort) |
12 |
> > + groups=${groups[*]} |
13 |
> > + echo "${groups// /,}" |
14 |
> > } |
15 |
> |
16 |
> Why don't you make groups a scalar variable (i.e., a comma separated |
17 |
> list) from the very beginning, if you're converting to it later anyway? |
18 |
> |
19 |
> local g groups=${egroups_arr[0]} |
20 |
> # sort supplementary groups to make comparison possible |
21 |
> while read -r g; do |
22 |
> [[ -n ${g} ]] && groups+=",${g}" |
23 |
> done < <(printf '%s\n' "${egroups_arr[@]:1}" | sort) |
24 |
> echo "${groups}" |
25 |
|
26 |
Indeed. Will do. |
27 |
|
28 |
-- |
29 |
Best regards, |
30 |
Michał Górny |