#!/usr/bin/perl -w
#
# This script works around idiocy added to GNU chmod recently wherein chmod
# will now complain when you try to chmod a file that you do not own with
# a relative permission (such as "g+w") that it already has.  Previous
# versions of GNU chmod would recognize this as a no-op and ignore the file.
#
# If your chmod is not in /bin you will need to change the penultimate line.
#
if(1<@ARGV and $ARGV[0] eq "g+w") {
	shift @ARGV;
	my @files=();
	my ($file,@stat);
	foreach $file (@ARGV) {
		push @files,$file unless(@stat=stat($file) and 0020 & $stat[2]);
	}
	exit 0 unless(@files);
	@ARGV=("g+w",@files);
}
exec {"/bin/chmod"} "chmod",@ARGV;
die "exec: $!";
