summaryrefslogtreecommitdiff
path: root/os2/perl2cmd.pl
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>2003-12-18 06:10:29 -0800
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-01-01 17:29:21 +0000
commit1933e12cd0d32c774bd7f483285802de52dc8cbc (patch)
treea2cdc2316a1e9964350869b0754cf42977a94088 /os2/perl2cmd.pl
parentb08eb2a88581a6164b7fe182bf291c86bfb3c690 (diff)
downloadperl-1933e12cd0d32c774bd7f483285802de52dc8cbc.tar.gz
OS/2 update
Message-ID: <20031218221029.GA7898@math.berkeley.edu> p4raw-id: //depot/perl@22032
Diffstat (limited to 'os2/perl2cmd.pl')
-rw-r--r--os2/perl2cmd.pl18
1 files changed, 16 insertions, 2 deletions
diff --git a/os2/perl2cmd.pl b/os2/perl2cmd.pl
index 4db40a0a31..07529ad8e8 100644
--- a/os2/perl2cmd.pl
+++ b/os2/perl2cmd.pl
@@ -2,6 +2,7 @@
# Note that we cannot put hashbang to be extproc to make Configure work.
use Config;
+use File::Compare;
$dir = shift;
$dir =~ s|/|\\|g ;
@@ -26,9 +27,11 @@ foreach $file (<$idir/*>) {
$base =~ s|\.pl$||;
#$file =~ s|/|\\|g ;
warn "Clashing output name for $file, skipping" if $seen{$base}++;
- print "Processing $file => $dir\\$base.cmd\n";
+ my $new = (-f "$dir/$base.cmd" ? '' : ' (new file)');
+ print "Processing $file => $dir/$base.cmd$new\n";
+ my $ext = ($new ? '.cmd' : '.tcm');
open IN, '<', $file or warn, next;
- open OUT, '>', "$dir/$base.cmd" or warn, next;
+ open OUT, '>', "$dir/$base$ext" or warn, next;
my $firstline = <IN>;
my $flags = '';
$flags = $2 if $firstline =~ /^#!\s*(\S+)\s+-([^#]+?)\s*(#|$)/;
@@ -36,5 +39,16 @@ foreach $file (<$idir/*>) {
print OUT $_ while <IN>;
close IN or warn, next;
close OUT or warn, next;
+ chmod 0444, "$dir/$base$ext";
+ next if $new;
+ if (compare "$dir/$base$ext", "$dir/$base.cmd") { # different
+ chmod 0666, "$dir/$base.cmd";
+ unlink "$dir/$base.cmd";
+ rename "$dir/$base$ext", "$dir/$base.cmd";
+ } else {
+ chmod 0666, "$dir/$base$ext";
+ unlink "$dir/$base$ext";
+ print "...unchanged...\n";
+ }
}