#!/usr/bin/perl -w
#
#NAME
#  caseCheck - find file names that differ by case
#
#SYNOPSIS
#  caseCheck [dir]..
#
#DESCRIPTION
#  This program  searches  through  the  listed  directories  (.   by
#  default)  and  looks for files whose names differ only by the case
#  of some letters.  The output shows the matches.
#
#  The main use is for  finding  problems  before  copying  files  to
#  system that don't distinguish case, such as OSX.
#
#OPTIONS
#
#EXAMPLES
#
#FILES
#
#BUGS
#
#SEE ALSO
#
#AUTHOR
#  John Chambers <jc@trillian.mit.edu>

$| = 1;
$exitstat = 0;
($P = $0) =~ s".*/"";
$V = $ENV{"V_$P"} || 1;

for $arg (@ARGV) {
	if (($flg,$opt) =~ ($arg =~ /^[-+]+(.+)/)) {
		while ($c = substr($opt,0,1,'') {
		}
	} elsif (-d $arg) {
		push @dirs, $arg;
	} else {
		print STDERR "$0: \"$arg\" is neither option nor directory.\n";
	}
}
push @dirs, '.' unless @dirs;

for $dir (@dirs) {
	&scandir($dir);
}

exit $exitstat;

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub scandir{
	local($d) = @_;
	local(*D,$f,@files);
	unless (open(D,$d)) {
		print STDERR "$0: Can't read \"$d\"\n";
		return undef;
	}

}
