Skip to content

Commit

Permalink
[UI] Do not call GetTerminalSize() if STDOUT is not a TTY by adopting…
Browse files Browse the repository at this point in the history
… PR #86 of @guillaume-uH57J9 (Debian Bug#859387 by by Paul Wise <pabs@debian.org>; closes #86).
  • Loading branch information
liske committed Nov 1, 2017
1 parent c923196 commit 4e13810
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ needrestart (2.12) unstable; urgency=medium
(github issue #72 by Stefan Bühler @stbuehler)
- [Core] Add missing unnamed device major numbers (fix for OpenVZ).
(Debian Bug#876452 by Piotr Pańczyk <piotr.panczyk@assecobs.pl>)
- [UI] Do not call GetTerminalSize() if STDOUT is not a TTY.
(Debian Bug#859387 by by Paul Wise <pabs@debian.org>)
(github issues #85 and #86 by @guillaume-uH57J9)

-- Thomas Liske <thomas@fiasko-nw.net>

Expand Down
14 changes: 10 additions & 4 deletions perl/lib/NeedRestart/UI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ sub wprint {
my $sp2 = shift;
my $message = shift;

# workaround Debian Bug#824564 in Term::ReadKey: pass filehandle twice
my ($cols) = GetTerminalSize($fh, $fh);
$columns = $cols if($cols);
# only wrap output if it is a terminal
if (-t $fh) {
# workaround Debian Bug#824564 in Term::ReadKey: pass filehandle twice
my ($cols) = GetTerminalSize($fh, $fh);
$columns = $cols if($cols);

print $fh wrap($sp1, $sp2, $message);
print $fh wrap($sp1, $sp2, $message);
}
else {
print $fh "$sp1$message";
}
}

sub progress_prep($$$) {
Expand Down
4 changes: 2 additions & 2 deletions perl/lib/NeedRestart/UI/stdio.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sub _announce {
kversion => $vars{KVERSION},
message => $message,
));
<STDIN>;
<STDIN> if (-t *STDIN && -t *STDOUT);
}


Expand Down Expand Up @@ -76,7 +76,7 @@ You should consider rebooting!
EHINT

<STDIN>;
<STDIN> if (-t *STDIN && -t *STDOUT);
}


Expand Down

0 comments on commit 4e13810

Please sign in to comment.