Signed-off-by: Michał Górny <mgo...@gentoo.org>
---
 eclass/user.eclass | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/eclass/user.eclass b/eclass/user.eclass
index fdf98caa6099..b237abdda045 100644
--- a/eclass/user.eclass
+++ b/eclass/user.eclass
@@ -445,11 +445,13 @@ egetgroups() {
        local egroups_arr
        read -r -a egroups_arr < <(id -G -n "$1")
 
-       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// /,}"
 }
 
 # @FUNCTION: esethome
-- 
2.22.0


Reply via email to