From 1cd4c59f9949f57833982990553b02c535fadde6 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Tue, 15 Mar 2011 18:43:41 +0000 Subject: Slightly safer operation on RO svn path=/trunk/netsurf/; revision=12064 --- utils/svn-testament.pl | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'utils') diff --git a/utils/svn-testament.pl b/utils/svn-testament.pl index 3f2065111..ba99124d4 100755 --- a/utils/svn-testament.pl +++ b/utils/svn-testament.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl -w use strict; +use File::Temp; =head1 @@ -24,8 +25,20 @@ if ( -d ".svn" ) { $svn_present = 1; } +sub gather_output { + my $cmd = shift; + my $tmpfile = File::Temp::tmpnam(); + local $/ = undef(); + system("$cmd > $tmpfile"); + open CMDH, "<", $tmpfile; + my $ret = ; + close CMDH; + unlink($tmpfile); + return $ret; +} + if ( $svn_present ) { - foreach my $line (split(/\n/, `svn info $root`)) { + foreach my $line (split(/\n/, gather_output("svn info $root"))) { my ($key, $value) = split(/: /, $line, 2); $key = lc($key); $key =~ s/\s+//g; @@ -40,7 +53,7 @@ if ( $svn_present ) { my %svnstatus; # The SVN status output if ( $svn_present ) { - foreach my $line (split(/\n/, `svn status $root`)) { + foreach my $line (split(/\n/, gather_output("svn status $root"))) { chomp $line; my $op = substr($line, 0, 1); if ($op eq ' ' && substr($line, 1, 1) ne ' ') { $op = "p"; } @@ -65,7 +78,7 @@ my %userinfo; # The information about the current user # The current date, in AmigaOS version friendly format (dd.mm.yyyy) my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); -my $compiledate = sprintf("%d.%d.%d",$mday,$mon+1,$year+1900); +my $compiledate = sprintf("%02d.%02d.%d",$mday,$mon+1,$year+1900); chomp $compiledate; # Spew the testament out @@ -82,7 +95,7 @@ my $hostname = $ENV{HOSTNAME}; unless ( defined($hostname) && $hostname ne "") { # Try hostname command if env-var empty - $hostname = `hostname`; + $hostname = gather_output("hostname"); chomp $hostname; } -- cgit v1.2.3