From: Simon Amor Date: Fri, 27 Jan 2017 15:45:13 +0000 (+0000) Subject: Change behaviour for terminal width detection X-Git-Tag: 5.90115~3^2^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=b4ed26ff40a4cad56a4b088ba0cf006bfde8df82 Change behaviour for terminal width detection Sometimes Term::Size::Any is installed but can return a width of undef. This causes the eval to succeed but then it falls back to using 80 characters. This change allows it to look at $ENV{COLUMNS} for a hint if the width isn't defined or if the eval fails due to a missing module instead of just if the eval returns an error. --- diff --git a/lib/Catalyst/Utils.pm b/lib/Catalyst/Utils.pm index 9fb1e92..fc877d4 100644 --- a/lib/Catalyst/Utils.pm +++ b/lib/Catalyst/Utils.pm @@ -413,11 +413,14 @@ sub term_width { } else { warn "There was an error trying to detect your terminal size: $@\n"; } + }; + + unless ($width) { warn 'Trouble trying to detect your terminal size, looking at $ENV{COLUMNS}'."\n"; $width = $ENV{COLUMNS} if exists($ENV{COLUMNS}) && $ENV{COLUMNS} =~ m/^\d+$/; - }; + } do { warn "Cannot determine desired terminal width, using default of 80 columns\n";