when you try to use check-mime-type.pl on Windows, you unfortunately get
errors like "svnlook ... failed with no output".
By searching for similar errors I came across
which then led me to the following two pages
According to the PerlPort doc I see these script problems as a
bug/shortcoming of those scripts.
I would like to see that the most common hook scripts are written in an
OS-independent way, or at least take care of OS-specialities like pipes.
Subversion is a cross-platform Version Control System and not every new
user is used to Perl/Python to adopt the scripts to their OS.
Maybe a standardized "safe_read_from_pipe" Perl sub can be developed,
that works for all Subversion target systems.
Does anyone agree on this? Or I'm the only one using hook scripts on
As I do not want to only "complain" but also to contribute, I tried and
was able to make the script work on my Windows XP SP2 with the
information from the above URLs.
The resulting patch is attached to this mail.
I hope that this patch can be tested on/reviewed for other OSes and get
into the official script posted in the "Tools & Contrib" section.
For the people interested in how to implement a this hook script on
Windows [XP], here are the important lines of my pre-commit.bat for
REM *** Check MIME types
D:\Repositories\SVN\_Scripts\check-mime-type.pl "%1" "%2"
if not errorlevel 1 goto check_mime_ok
set /A RC_ALL+=1
REM *** All checks done
echo All checks done. RC=%RC_ALL% 1>&2
--- check-mime-type.pl (revision 6)
+++ check-mime-type.pl (working copy)
@@ -112,15 +112,15 @@
-foreach my $path ( @files_added )
+foreach my $path ( @files_added )
# Parse the complete list of property values of the file $path to extract
# the mime-type and eol-style
- foreach my $prop (&read_from_process($svnlook, 'proplist', $repos, '-t',
- $txn, '--verbose', $path))
+ foreach my $prop (&read_from_process($svnlook, 'proplist', $repos, '-t',
+ $txn, '--verbose', '"' . $path . '"')) # Windows: files with spaces have to be put in quotes
if ($prop =~ /^\s*svn:mime-type : (\S+)/)
@@ -180,6 +180,10 @@
die "usage: $0 REPOS TXN-NAME\n";
+# Windows/DOS: can not use openforks ('-|')
+# see http://perldoc.perl.org/perlport.html#Interprocess-Communication-(IPC)
+# see http://perldoc.perl.org/perlport.html#PLATFORMS
+my $openfork_available = ($^O ne "MSWin32") && ($^O ne "dos");
@@ -187,6 +191,8 @@
croak "$0: safe_read_from_pipe passed no arguments.\n";
print "Running @_\n";
+ if ($openfork_available)
my $pid = open(SAFE_READ, '-|');
unless (defined $pid)
@@ -194,11 +200,48 @@
+ # child
or die "$0: cannot dup STDOUT: $!\n";
or die "$0: cannot exec `@_': $!\n";
+ # Redirect the comment into a temp file and use that to work around
+ # Windoze's (non-)handling of multi-line commands.
+ my @commandline = ();
+ my $command;
+ while ($command = shift)
+ if ("-m" eq $command)
+ my $comment = shift;
+ my ($handle, $tmpfile) = tempfile( DIR => $tmp_dir);
+ print $handle $comment;
+ push(@commandline, "--file");
+ push(@commandline, $tmpfile);
+ if ($command =~ m"\n")
+ warn "$0: carriage return detected in command - may not work\n";
+ push(@commandline, $command);
+ # Now do the pipe.
+ open(SAFE_READ, "@commandline |")
+ or die "$0: cannot pipe to command: $!\n";
+ # parent
To unsubscribe, e-mail: firstname.lastname@example.org
For additional commands, e-mail: email@example.com
Received on Wed Aug 15 01:24:25 2007