user.eclass: enewgroup, allow -1 as gid
authorMichał Górny <mgorny@gentoo.org>
Fri, 31 Jan 2020 14:56:48 +0000 (15:56 +0100)
committerMichał Górny <mgorny@gentoo.org>
Wed, 26 Feb 2020 10:28:27 +0000 (11:28 +0100)
Allow using '-1' to specify 'next free GID' for enewgroup.  While
technically this can already be specified by omitting gid, allowing -1
improves consistency with enewuser.

Closes: https://bugs.gentoo.org/707508
Signed-off-by: Michał Górny <mgorny@gentoo.org>
eclass/user.eclass

index a33915e21192fb8e838e5e3aebcd9002060eb554..b70698356a3ab85bd9839c441cf42da47c00a1c0 100644 (file)
@@ -252,7 +252,7 @@ enewgroup() {
 
        # handle gid
        local egid=$1; shift
-       if [[ ! -z ${egid} ]] ; then
+       if [[ -n ${egid} && ${egid} != -1 ]] ; then
                if [[ ${egid} -gt 0 ]] ; then
                        if [[ -n $(egetent group ${egid}) ]] ; then
                                [[ -n ${force_gid} ]] && die "${FUNCNAME}: GID ${egid} already taken"