From: Avery Pennarun Date: Wed, 16 Feb 2011 23:55:24 +0000 (-0800) Subject: cmd/newliner: avoid printing a blank line if the final output ended in \r. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=f36b287401a4e2848ffb01c414d10aea854688e8;p=packages%2Fb%2Fbup.git cmd/newliner: avoid printing a blank line if the final output ended in \r. If the last output was a progress message, we would blank out the line (which was correct) but then we'd print a newline, which was wrong. Only print the leftover output, followed by a newline, if the last output was nonempty. 'bup midx' suffered from this. Signed-off-by: Avery Pennarun --- diff --git a/cmd/newliner-cmd.py b/cmd/newliner-cmd.py index 90f88d8..966725e 100755 --- a/cmd/newliner-cmd.py +++ b/cmd/newliner-cmd.py @@ -32,7 +32,6 @@ while 1: else: assert(len(l) == 3) (line, splitchar, all) = l - #splitchar = '\n' sys.stdout.write('%-*s%s' % (lastlen, line, splitchar)) if splitchar == '\r': lastlen = len(line) @@ -40,5 +39,7 @@ while 1: lastlen = 0 sys.stdout.flush() -if lastlen or all: - sys.stdout.write('%-*s\n' % (lastlen, all)) +if lastlen: + sys.stdout.write('%-*s\r' % (lastlen, '')) +if all: + sys.stdout.write('%s\n' % all)