From: Jarkko Hietaniemi Date: Mon, 2 Nov 1998 09:10:33 +0000 (+0000) Subject: Prefer groups(1). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d0f88fcc9c7c03c807a5815903c49287c8492866;p=p5sagit%2Fp5-mst-13.2.git Prefer groups(1). id -Gn can be broken. id -a can save the day. p4raw-id: //depot/cfgperl@2179 --- diff --git a/t/op/groups.t b/t/op/groups.t index b2e7663..1eef0bf 100755 --- a/t/op/groups.t +++ b/t/op/groups.t @@ -2,7 +2,26 @@ $ENV{PATH} = '/usr/xpg4/bin:/bin:/usr/bin:/usr/ucb'; -unless (($groups = `(id -Gn || groups) 2>/dev/null`) ne '') { +# We have to find a command that prints all (effective +# and real) group names (not ids). The known commands are: +# groups +# id -Gn +# id -a +# Beware 1: some systems do just 'id -G' even when 'id -Gn' is used. +# Beware 2: the 'id -a' output format is tricky. + +GROUPS: { + last GROUPS if ($groups = `groups 2>/dev/null`) ne ''; + if ($groups = `id -Gn 2>/dev/null` ne '') { + last GROUPS unless $groups =~ /^(\d+)(\s+\d)*$/; + } + if ($groups = `id -a 2>/dev/null` ne '') { + if (/groups=/g && (@g = /\((.+?)\)/g)) { + $groups = join(" ", @g); + last GROUPS; + } + } + # Okay, not today. print "1..0\n"; exit 0; }