tags 942759 + patch thanks Hello,
Here is how to get a terminal that indicates width=0: - In Emacs - C-x d /su:root@localhost: RET - M-x shell RET, select a shell, enter the root password - stty --all The last command prints "columns 0". I suggest the below fix: if the width is 0, then use a sane default. I have submitted it upstream: https://github.com/liske/needrestart/pull/167 diff --git a/perl/lib/NeedRestart/UI.pm b/perl/lib/NeedRestart/UI.pm index 1e6a2f4..3d7c69e 100644 --- a/perl/lib/NeedRestart/UI.pm +++ b/perl/lib/NeedRestart/UI.pm @@ -127,13 +127,25 @@ sub _progress_inc { $self->_progress_out(); } +# my $columns = &_get_columns; +# Return the number of columns to use for output. +sub _get_columns { + my $default_columns = 80; # Sane default + if (-t *STDOUT) { + ($columns) = GetTerminalSize(\*STDOUT); + + # Cope with 0-width terminals. + # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=942759 + return $columns == 0? $default_columns: $columns; + } + else { + return $default_columns; + } +} + sub _progress_out { my $self = shift; - my $columns = 80; - - ($columns) = GetTerminalSize(\*STDOUT) if (-t *STDOUT); - - $columns -= 3; + my $columns = _get_columns; my $wmsg = int($columns * 0.7); $wmsg = length($self->{progress}->{msg}) if(length($self->{progress}->{msg}) < $wmsg); my $wbar = $columns - $wmsg - 1; @@ -143,12 +155,10 @@ sub _progress_out { sub _progress_fin { my $self = shift; - my $columns = 80; + my $columns = _get_columns; $self->{progress}->{count} = 0; - ($columns) = GetTerminalSize(\*STDOUT) if (-t *STDOUT); - print $self->{progress}->{msg}, ' ' x ($columns - length($self->{progress}->{msg})), "\n"; } Thanks! Best regards -- Fabrice Bauzac-Stehly PGP 015AE9B25DCB0511D200A75DE5674DEA514C891D