# Disable progress bar while running non-interactive.
# Closes: #768124

diff --git a/perl/lib/NeedRestart/UI.pm b/perl/lib/NeedRestart/UI.pm
index 2441755..55f170e 100644
--- a/perl/lib/NeedRestart/UI.pm
+++ b/perl/lib/NeedRestart/UI.pm
@@ -42,7 +42,7 @@ sub progress_prep($$$) {
     my $self = shift;
     my ($max, $out) = @_;
 
-    unless($self->{debug}) {
+    unless($self->{debug} || !exists($ENV{COLUMNS}) || !exists($ENV{LINES})) {
 	# restore terminal if required (debconf)
 	unless(-t *STDIN) {
 	    open($self->{fhin}, '<&', \*STDIN) || die "Can't dup stdin: $!\n";
-- 
2.1.3
