                                                                                                                                                                                                                                                               
Delivered-To: richih.mailinglist+debian.org@gmail.com
Received: by 10.27.219.143 with SMTP id s137csp1413758wlg;
        Sat, 5 Dec 2015 21:24:40 -0800 (PST)
X-Received: by 10.28.91.9 with SMTP id p9mr12936595wmb.18.1449379480304;
        Sat, 05 Dec 2015 21:24:40 -0800 (PST)
Return-Path: <pabs3@bonedaddy.net>
Received: from master.debian.org (master.debian.org. [2001:41b8:202:deb:216:36ff:fe40:4001])
        by mx.google.com with ESMTPS id jy10si28809403wjb.55.2015.12.05.21.24.38
        for <richih.mailinglist+debian.org@gmail.com>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sat, 05 Dec 2015 21:24:38 -0800 (PST)
Received-SPF: softfail (google.com: domain of transitioning pabs3@bonedaddy.net does not designate 2001:41b8:202:deb:216:36ff:fe40:4001 as permitted sender) client-ip=2001:41b8:202:deb:216:36ff:fe40:4001;
Authentication-Results: mx.google.com;
       spf=softfail (google.com: domain of transitioning pabs3@bonedaddy.net does not designate 2001:41b8:202:deb:216:36ff:fe40:4001 as permitted sender) smtp.mailfrom=pabs3@bonedaddy.net
Received: from localhost ([::1] helo=chianamo.localdomain)
	by master.debian.org with esmtp (Exim 4.84)
	(envelope-from <pabs3@bonedaddy.net>)
	id 1a5RoM-0000DE-Bi; Sun, 06 Dec 2015 05:24:38 +0000
From: Paul Wise <pabs3@bonedaddy.net>
To: Joey Hess <joeyh@joeyh.name>,
	Richard Hartmann <richih@debian.org>
Cc: Paul Wise <pabs3@bonedaddy.net>
Subject: [myrepos] [PATCH 2/4] In continuous output mode print the currently running command.
Date: Sun,  6 Dec 2015 13:24:17 +0800
Message-Id: <1449379459-3296-2-git-send-email-pabs3@bonedaddy.net>
X-Mailer: git-send-email 2.6.2
In-Reply-To: <1449379459-3296-1-git-send-email-pabs3@bonedaddy.net>
References: <1449379459-3296-1-git-send-email-pabs3@bonedaddy.net>

This doesn't switch to the next line until there is some output
so this feature functions like a kind of progress indicator.

When mr is interrupted, it needs to erase the currently running command
otherwise the output will get corrupted by the interrupted message.
---
 mr | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mr b/mr
index 0c95bc6..d10d5b5 100755
--- a/mr
+++ b/mr
@@ -609,6 +609,7 @@ my $jobs=1;
 my $trust_all=0;
 my $directory=getcwd();
 my $terminal=-t STDOUT && eval{require IO::Pty::Easy;IO::Pty::Easy->import();1;};
+my $erase_line=$terminal && eval{require Term::Cap;my $t=Term::Cap->Tgetent();$t->Tputs('ce');};
 
 my $HOME_MR_CONFIG = "$ENV{HOME}/.mrconfig";
 $ENV{MR_CONFIG}=find_mrconfig();
@@ -765,10 +766,12 @@ sub terminal_friendly_spawn {
 		my $pty = IO::Pty::Easy->new;
 		$pty->spawn($sh);
 		if ($continous) {
+			$| = 1;
+			print "$actionmsg$erase_line\r" if $actionmsg;
 			while ($pty->is_active) {
 				my $data = $pty->read();
 				if (defined $data && $data ne '') {
-					print "$actionmsg\n" if ($actionmsg && !$continous_output);
+					print "\n" if ($actionmsg && !$continous_output);
 					$continous_output = 1;
 					print $data;
 				}
@@ -1924,6 +1927,7 @@ sub check {
 
 sub init {
 	$SIG{INT}=sub {
+		print STDERR "$erase_line" if defined $erase_line && $terminal && !$quiet && $minimal && 1 == $jobs;
 		print STDERR "mr: interrupted\n";
 		exit 2;
 	};
-- 
2.6.2

