#!/usr/bin/perl -w sub help { print "win_preimport filenames\n"; print "Converts all files not marked by CVS as binary to UNIX text format\n"; exit; } sub is_binary { my $cvs_status=qx{cvs status $_ 2>/dev/null}; my $re=qr{Sticky Options:\s+-kb}; return 1 if($cvs_status=~/$re/s); return 0; } sub convert_line_endings { my $fname=$_; my $tmpname=$_."tmp"; open(TMP,">$tmpname") or die("Can't create temporary file: $!\n"); open(FILE,"<$fname") or die("Can't open file: $!\n"); while(){ chomp; s/\r$//; print TMP $_,"\n"; } close FILE; close TMP; rename($tmpname,$fname); } help unless @ARGV; for(@ARGV){ chomp; if(is_binary){ print "$_ is binary\n"; } else{ print "Converting $_ to UNIX text file format\n"; convert_line_endings; } }