This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix Porting/cmpVERSION.pl to work on Win32
[perl5.git] / Porting / cmpVERSION.pl
old mode 100644 (file)
new mode 100755 (executable)
index 22241c4..dd3d20c
@@ -39,7 +39,9 @@ die "$0: '$source_dir' does not look like a Perl directory\n"
 die "$0: '$source_dir' is a Perl directory but does not look like Git working directory\n"
     unless -d catdir($source_dir, ".git");
 
 die "$0: '$source_dir' is a Perl directory but does not look like Git working directory\n"
     unless -d catdir($source_dir, ".git");
 
-my $tag_exists = `git --no-pager tag -l $tag_to_compare 2>/dev/null`;
+my $null = $^O eq 'MSWin32' ? 'nul' : '/dev/null';
+
+my $tag_exists = `git --no-pager tag -l $tag_to_compare 2>$null`;
 chomp $tag_exists;
 
 die "$0: '$tag_to_compare' is not a known Git tag\n"
 chomp $tag_exists;
 
 die "$0: '$tag_to_compare' is not a known Git tag\n"
@@ -78,7 +80,7 @@ my @module_diffs = grep {
     $this_dir = $1 if m/^(.*)\//;
     /\.pm$/ &&
     (!defined($this_dir) || ($this_dir !~ $skip_dirs)) &&
     $this_dir = $1 if m/^(.*)\//;
     /\.pm$/ &&
     (!defined($this_dir) || ($this_dir !~ $skip_dirs)) &&
-    !exists $skip{$_} && 
+    !exists $skip{$_} &&
     !exists $dual_files{$_}
 } @all_diffs;
 
     !exists $dual_files{$_}
 } @all_diffs;
 
@@ -97,10 +99,9 @@ foreach my $pm_file (@module_diffs) {
     my $pm_version = eval {MM->parse_version($pm_file)};
     my $orig_pm_content = get_file_from_git($pm_file, $tag_to_compare);
     my $orig_pm_version = eval {MM->parse_version(\$orig_pm_content)};
     my $pm_version = eval {MM->parse_version($pm_file)};
     my $orig_pm_content = get_file_from_git($pm_file, $tag_to_compare);
     my $orig_pm_version = eval {MM->parse_version(\$orig_pm_content)};
-    next unless
-       defined $pm_version &&
-       defined $orig_pm_version &&
-        $pm_version eq $orig_pm_version;
+    next if ( ! defined $pm_version || ! defined $orig_pm_version );
+    next if ( $pm_version eq 'undef' || $orig_pm_version eq 'undef' ); # sigh
+    next if $pm_version ne $orig_pm_version;
     push @output_files, $pm_file;
     push @output_diffs, $pm_file unless $pm_eq;
     push @output_diffs, $xs_file unless $xs_eq;
     push @output_files, $pm_file;
     push @output_diffs, $pm_file unless $pm_eq;
     push @output_diffs, $xs_file unless $xs_eq;
@@ -108,7 +109,7 @@ foreach my $pm_file (@module_diffs) {
 
 sub compare_git_file {
     my ($file, $tag) = @_;
 
 sub compare_git_file {
     my ($file, $tag) = @_;
-    open(my $orig_fh, "-|", "git --no-pager show $tag:$file 2>/dev/null");
+    open(my $orig_fh, "-|", "git --no-pager show $tag:$file 2>$null");
     return undef if eof($orig_fh);
     my $is_eq = compare($file, $orig_fh) == 0;
     close($orig_fh);
     return undef if eof($orig_fh);
     my $is_eq = compare($file, $orig_fh) == 0;
     close($orig_fh);
@@ -118,7 +119,7 @@ sub compare_git_file {
 sub get_file_from_git {
     my ($file, $tag) = @_;
     local $/ = undef;
 sub get_file_from_git {
     my ($file, $tag) = @_;
     local $/ = undef;
-    my $file_content = `git --no-pager show $tag:$file 2>/dev/null`;
+    my $file_content = `git --no-pager show $tag:$file 2>$null`;
     return $file_content;
 }
 
     return $file_content;
 }