]> arthur.barton.de Git - bup.git/commitdiff
cmd/newliner: avoid printing a blank line if the final output ended in \r.
authorAvery Pennarun <apenwarr@gmail.com>
Wed, 16 Feb 2011 23:55:24 +0000 (15:55 -0800)
committerAvery Pennarun <apenwarr@gmail.com>
Wed, 16 Feb 2011 23:56:34 +0000 (15:56 -0800)
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 <apenwarr@gmail.com>
cmd/newliner-cmd.py

index 90f88d8629845b92c86f6f4f9d0b30d463a75e78..966725e8fe8ac337e8bc00d70f240f6ae54bff1c 100755 (executable)
@@ -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)