From 0d2164fb4033f1db0a0cac3abbc09ac83629d9d2 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 12 Dec 2010 09:50:13 +0100 Subject: Don't try to cut off stuff when there's no terminal width available --- bin/icli | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/icli b/bin/icli index 2c80c23..8b8ef69 100755 --- a/bin/icli +++ b/bin/icli @@ -143,14 +143,21 @@ sub break_str { my ($text, $waste) = @_; my $cut = $term_width - $waste; + if ( + (not defined $term_width) or + ($term_width == 0) or + ($cut < 12)) { + return $text; + } + if ($cut_mode eq 'c') { - return(substr($text, 0, $cut)); + return substr($text, 0, $cut); } elsif ($cut_mode eq 'b') { - return(join("\n", split_by_words($text, $waste, $cut))); + return join("\n", split_by_words($text, $waste, $cut)); } else { - return($text); + return $text; } } -- cgit v1.2.3