summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2010-12-12 09:50:13 +0100
committerDaniel Friesel <derf@finalrewind.org>2010-12-12 09:50:13 +0100
commit0d2164fb4033f1db0a0cac3abbc09ac83629d9d2 (patch)
tree389dce6b31b8ecbd287bc5fcbb8a9990b074bdbc
parent14a3c31190e310f46a3028d1b3b0c078fcad4011 (diff)
Don't try to cut off stuff when there's no terminal width available
-rwxr-xr-xbin/icli13
1 files changed, 10 insertions, 3 deletions
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;
}
}