aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-10-23 12:48:46 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-10-23 12:48:46 +0100
commita9eb6707b478f28b0d2e61cb264ddf56b3342015 (patch)
tree33b1e2b0559f0a853d7899fe15d1f0bdc837d3c5
parentc0923031e00cc788a954483f4963069803c725b8 (diff)
Don't use chdir in graph generation scripts.
Running the graph scripts from their directory does not work with perl 5.16+, as the chdir interferes with FindBin's operation. Fixes #1262.
-rwxr-xr-xbin/problem-creation-graph8
-rwxr-xr-xbin/problems-filed-graph8
2 files changed, 8 insertions, 8 deletions
diff --git a/bin/problem-creation-graph b/bin/problem-creation-graph
index c3d10f934..9fb4501a3 100755
--- a/bin/problem-creation-graph
+++ b/bin/problem-creation-graph
@@ -10,12 +10,12 @@ use strict;
use warnings;
require 5.8.0;
+my $DIR;
BEGIN {
use File::Basename qw(dirname);
use File::Spec;
- my $d = dirname(File::Spec->rel2abs($0));
- chdir "$d/..";
- require "$d/../setenv.pl";
+ $DIR = dirname(dirname(File::Spec->rel2abs($0)));
+ require "$DIR/setenv.pl";
}
use File::Temp qw(tempfile);
@@ -113,6 +113,6 @@ $gp .= <<END;
"< awk 'BEGIN { n = 0 } { n += \$2; print \$1, \$2, n; }' $sources{unconfirmed}" using 1:3 axes x1y2 with lines lt 0 title "cumulative total number of problems"
END
-open(my $gnuplot, '|-', "GDFONTPATH=/usr/share/fonts/truetype/ttf-bitstream-vera gnuplot > web/fms-live-creation$config{extension} 2> /dev/null");
+open(my $gnuplot, '|-', "GDFONTPATH=/usr/share/fonts/truetype/ttf-bitstream-vera gnuplot > $DIR/web/fms-live-creation$config{extension} 2> /dev/null");
$gnuplot->print($gp);
close $gnuplot;
diff --git a/bin/problems-filed-graph b/bin/problems-filed-graph
index abfe0cf1a..cb8851b7f 100755
--- a/bin/problems-filed-graph
+++ b/bin/problems-filed-graph
@@ -10,12 +10,12 @@ use strict;
use warnings;
require 5.8.0;
+my $DIR;
BEGIN {
use File::Basename qw(dirname);
use File::Spec;
- my $d = dirname(File::Spec->rel2abs($0));
- chdir "$d/..";
- require "$d/../setenv.pl";
+ $DIR = dirname(dirname(File::Spec->rel2abs($0)));
+ require "$DIR/setenv.pl";
}
use File::Temp qw(tempfile);
@@ -62,6 +62,6 @@ my $gp = <<END;
plot "$source" using 1:2 with lines axes x1y2 lt 3 title "FixMyStreet problem reports"
END
-open(my $gnuplot, '|-', "GDFONTPATH=/usr/share/fonts/truetype/ttf-bitstream-vera gnuplot > web/fms-live-line$config{extension} 2> /dev/null");
+open(my $gnuplot, '|-', "GDFONTPATH=/usr/share/fonts/truetype/ttf-bitstream-vera gnuplot > $DIR/web/fms-live-line$config{extension} 2> /dev/null");
$gnuplot->print($gp);
close $gnuplot;