mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-27 16:59:36 +03:00
Slightly safer operation on RO
svn path=/trunk/netsurf/; revision=12064
This commit is contained in:
parent
a81a7b5af2
commit
1cd4c59f99
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use File::Temp;
|
||||||
|
|
||||||
=head1
|
=head1
|
||||||
|
|
||||||
@ -24,8 +25,20 @@ if ( -d ".svn" ) {
|
|||||||
$svn_present = 1;
|
$svn_present = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub gather_output {
|
||||||
|
my $cmd = shift;
|
||||||
|
my $tmpfile = File::Temp::tmpnam();
|
||||||
|
local $/ = undef();
|
||||||
|
system("$cmd > $tmpfile");
|
||||||
|
open CMDH, "<", $tmpfile;
|
||||||
|
my $ret = <CMDH>;
|
||||||
|
close CMDH;
|
||||||
|
unlink($tmpfile);
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
if ( $svn_present ) {
|
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);
|
my ($key, $value) = split(/: /, $line, 2);
|
||||||
$key = lc($key);
|
$key = lc($key);
|
||||||
$key =~ s/\s+//g;
|
$key =~ s/\s+//g;
|
||||||
@ -40,7 +53,7 @@ if ( $svn_present ) {
|
|||||||
my %svnstatus; # The SVN status output
|
my %svnstatus; # The SVN status output
|
||||||
|
|
||||||
if ( $svn_present ) {
|
if ( $svn_present ) {
|
||||||
foreach my $line (split(/\n/, `svn status $root`)) {
|
foreach my $line (split(/\n/, gather_output("svn status $root"))) {
|
||||||
chomp $line;
|
chomp $line;
|
||||||
my $op = substr($line, 0, 1);
|
my $op = substr($line, 0, 1);
|
||||||
if ($op eq ' ' && substr($line, 1, 1) ne ' ') { $op = "p"; }
|
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)
|
# The current date, in AmigaOS version friendly format (dd.mm.yyyy)
|
||||||
|
|
||||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
|
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;
|
chomp $compiledate;
|
||||||
|
|
||||||
# Spew the testament out
|
# Spew the testament out
|
||||||
@ -82,7 +95,7 @@ my $hostname = $ENV{HOSTNAME};
|
|||||||
|
|
||||||
unless ( defined($hostname) && $hostname ne "") {
|
unless ( defined($hostname) && $hostname ne "") {
|
||||||
# Try hostname command if env-var empty
|
# Try hostname command if env-var empty
|
||||||
$hostname = `hostname`;
|
$hostname = gather_output("hostname");
|
||||||
chomp $hostname;
|
chomp $hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user