Fixes for the test suite on OS/2
[p5sagit/p5-mst-13.2.git] / t / op / groups.t
index 6110fb8..f682f61 100755 (executable)
@@ -56,6 +56,8 @@ GROUPS: {
     if (($groups = `id -a 2>/dev/null`) ne '') {
        # $groups is of the form:
        # uid=39957(gsar) gid=22(users) groups=33536,39181,22(users),0(root),1067(dev)
+       # FreeBSD since 6.2 has a fake id -a:
+       # uid=1001(tobez) gid=20(staff) groups=20(staff), 0(wheel), 68(dialer)
        last GROUPS if $groups =~ /groups=/;
     }
     if (($groups = `id -Gn 2>/dev/null`) ne '') {
@@ -90,15 +92,15 @@ print "# groups = $groups\n";
 # That is: do not \w, do not \S.
 if ($groups =~ /groups=(.+)( [ug]id=|$)/) {
     my $gr = $1;
-    my @g0 = split /,/, $gr;
+    my @g0 = split /, ?/, $gr;
     my @g1;
     # prefer names over numbers
     for (@g0) {
-        # 42(zot me)
+       # 42(zot me)
        if (/^(\d+)(?:\(([^)]+)\))?/) {
            push @g1, ($2 || $1);
        }
-        # zot me(42)
+       # zot me(42)
        elsif (/^([^(]*)\((\d+)\)/) {
            push @g1, ($1 || $2);
        }
@@ -129,15 +131,17 @@ for (split(' ', $()) {
     else {
        push(@gr, $_);
     }
-} 
+}
 
 print "# gr = @gr\n";
 
+my %did;
 if ($^O =~ /^(?:uwin|cygwin|interix|solaris)$/) {
        # Or anybody else who can have spaces in group names.
        $gr1 = join(' ', grep(!$did{$_}++, sort split(' ', join(' ', @gr))));
 } else {
-       $gr1 = join(' ', sort @gr);
+       # Don't assume that there aren't duplicate groups
+       $gr1 = join(' ', sort grep defined $_ && !$did{$_}++, @gr);
 }
 
 if ($Config{myuname} =~ /^cygwin_nt/i) { # basegroup on CYGWIN_NT has id = 0.