#!./perl
$ENV{PATH} ="/bin:/usr/bin:/usr/xpg4/bin:/usr/ucb" .
- exists $ENV{PATH} ? ":$ENV{PATH}" : "";
+ exists $ENV{PATH} ? ":$ENV{PATH}" : "" unless $^O eq 'VMS';
$ENV{LC_ALL} = "C"; # so that external utilities speak English
$ENV{LANGUAGE} = 'C'; # GNU locale extension
exit 0;
}
-quit() if (($^O eq 'MSWin32' || $^O eq 'NetWare') or $^O =~ /lynxos/i);
+quit() if (($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS')
+ or $^O =~ /lynxos/i);
# We have to find a command that prints all (effective
# and real) group names (not ids). The known commands are:
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 '') {
# 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);
}
else {
push(@gr, $_);
}
-}
+}
print "# gr = @gr\n";
-if ($^O =~ /^(?:uwin|cygwin|solaris)$/) {
+my %did;
+if ($^O =~ /^(?:uwin|cygwin|interix|solaris|linux)$/) {
# 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.