summaryrefslogtreecommitdiff
path: root/t/op/groups.t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1998-11-02 09:10:33 +0000
committerJarkko Hietaniemi <jhi@iki.fi>1998-11-02 09:10:33 +0000
commitd0f88fcc9c7c03c807a5815903c49287c8492866 (patch)
treee2954405a72082be26465954a6aa4faf26c12d99 /t/op/groups.t
parent64a0062a60726053d579d6ef49cb74b298839d3b (diff)
downloadperl-d0f88fcc9c7c03c807a5815903c49287c8492866.tar.gz
Prefer groups(1).
id -Gn can be broken. id -a can save the day. p4raw-id: //depot/cfgperl@2179
Diffstat (limited to 't/op/groups.t')
-rwxr-xr-xt/op/groups.t21
1 files changed, 20 insertions, 1 deletions
diff --git a/t/op/groups.t b/t/op/groups.t
index b2e766336b..1eef0bff5d 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;
}