Somehow I didn't recieve this message, sorry! On Thu, 9 Oct 2014 13:43:43 -0400 Joey Hess wrote:
> This fails if $data = "0", which I don't think is what you want > to check for here. You probably want to check if $data is defined, > or empty. ... > This and other else bracing is not in the code style used in mr. Fixed both in the attached pair of patches. -- bye, pabs https://wiki.debian.org/PaulWise
From 284ebd0a2f3ea0ae7bbd05f841bf114ab394cbbe Mon Sep 17 00:00:00 2001 From: Paul Wise <p...@debian.org> Date: Mon, 11 May 2015 22:02:08 +0800 Subject: [PATCH 1/2] Make output continuous in minimal mode when there is only one job Design choices include: Duplicate the loop to not check $continous for each output line. Make $continous an internal choice of terminal_friendly_spawn based on all the parameters so that each call of it behaves the same. Signed-off-by: Paul Wise <p...@debian.org> --- mr | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/mr b/mr index 6722d9a..b645c37 100755 --- a/mr +++ b/mr @@ -751,13 +751,28 @@ sub terminal_friendly_spawn { my $sh = shift; my $quiet = shift; my $minimal = shift; + my $jobs = shift; + my $continous = !$quiet && $minimal && 1 == $jobs; my $output = ""; + my $continous_output = 0; if ($terminal) { my $pty = IO::Pty::Easy->new; $pty->spawn($sh); - while ($pty->is_active) { - my $data = $pty->read(); - $output .= $data if defined $data; + if ($continous) { + while ($pty->is_active) { + my $data = $pty->read(); + if (defined $data && $data ne '') { + print "$actionmsg\n" if ($actionmsg && !$continous_output); + $continous_output = 1; + print $data; + } + } + } + else { + while ($pty->is_active) { + my $data = $pty->read(); + $output .= $data if defined $data; + } } $pty->close; } else { @@ -771,7 +786,7 @@ sub terminal_friendly_spawn { print "$actionmsg\n" if $actionmsg; print $output; } - return ($ret, $output ? 1 : 0); + return ($ret, ($output || $continous_output) ? 1 : 0); } sub action { @@ -876,7 +891,7 @@ sub action { $command, \@ARGV, sub { my $sh=shift; if (!$jobs || $jobs > 1 || $quiet || $minimal) { - return terminal_friendly_spawn($actionmsg, $sh, $quiet, $minimal); + return terminal_friendly_spawn($actionmsg, $sh, $quiet, $minimal, $jobs); } else { system($sh); @@ -941,7 +956,7 @@ sub hook { my ($ret,$out)=runsh $hook, $topdir, $subdir, $command, [], sub { my $sh=shift; if (!$jobs || $jobs > 1 || $quiet || $minimal) { - return terminal_friendly_spawn(undef, $sh, $quiet, $minimal); + return terminal_friendly_spawn(undef, $sh, $quiet, $minimal, $jobs); } else { system($sh); -- 2.1.4
From 7fc9ee4786379330565dd3d23b9a236a59a9a0a5 Mon Sep 17 00:00:00 2001 From: Paul Wise <p...@debian.org> Date: Mon, 11 May 2015 22:03:47 +0800 Subject: [PATCH 2/2] Use the same code format in terminal_friendly_spawn as elsewhere. Signed-off-by: Paul Wise <p...@debian.org> --- mr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mr b/mr index b645c37..427ab0a 100755 --- a/mr +++ b/mr @@ -775,14 +775,16 @@ sub terminal_friendly_spawn { } } $pty->close; - } else { + } + else { $output = qx/$sh 2>&1/; } my $ret = $?; if ($quiet && $ret != 0) { print "$actionmsg\n" if $actionmsg; print STDERR $output; - } elsif (!$quiet && (!$minimal || $output)) { + } + elsif (!$quiet && (!$minimal || $output)) { print "$actionmsg\n" if $actionmsg; print $output; } -- 2.1.4
signature.asc
Description: This is a digitally signed message part