getgid from coreutils 6.12

Elan Ruusamäe glen at pld-linux.org
Fri Aug 29 16:57:40 CEST 2008


looks like coreutils has got itself getgid(1), which usage differs from pld version.
more precisely it says error instead of nothing when gid doesn't exist:

coreutils-6.12-2.x86_64:
$ getgid root; echo $?
0
0
$ getgid foo; echo $?
getgid: cannot find group name `foo'
1

coreutils-6.9-1.amd64:

$ getgid root; echo $?
0
0
$ getgid foo; echo $?
1

as our %groupadd uses getgid, now with new coreutils there's noise on screen:
Preparing...                ########################################### [100%]
/usr/bin/getgid: cannot find group name `vbox'
Adding group vbox GID=221.
   1:VirtualBox             ########################################### [100%]

if [ -n "`/usr/bin/getgid %{1}`" ]; then \
    if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
        echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
        exit 1 \
    fi \

my question would be, should we just perhaps check exit code from getgid [1], 
not output, or make change to discard error output [2]?

[1]
if [ -n "`/usr/bin/getgid %{1} 2>/dev/null`" ]; then \
    if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
        echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
        exit 1 \
    fi \

[2]
if ! /usr/bin/getgid %{1} > /dev/null 2>&1; then \
    if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
        echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
        exit 1 \
    fi \

-- 
glen


More information about the pld-devel-en mailing list