File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ my $VERSION = "1.2.7";
4
4
5
5
# ################################################################################
6
6
7
+ use 5.010; # Require Perl 5.10 for 'state' variables
7
8
use File::Spec; # For catdir
8
9
use File::Basename; # For dirname
9
10
use Encode; # For handling UTF8 stuff
@@ -588,7 +589,18 @@ sub trim {
588
589
# Print a line of em-dash or line-drawing chars the full width of the screen
589
590
sub horizontal_rule {
590
591
my $color = $_ [0] || " " ;
591
- my $width = $ruler_width || ` tput cols` ;
592
+
593
+ # Make width static so we only calculate it once
594
+ state $width ;
595
+ if (!$width ) {
596
+ my $tput = ` tput cols 2>1` ;
597
+ if (!$tput ) {
598
+ print color(' orange' ) . " Warning: `tput cols` did not return numeric input" . color(' reset' ) . " \n " ;
599
+ $tput = 80;
600
+ }
601
+
602
+ $width = $ruler_width || $tput ;
603
+ }
592
604
593
605
if (is_windows()) {
594
606
$width --;
You can’t perform that action at this time.
0 commit comments