]> arthur.barton.de Git - bup.git/commitdiff
cmd/newliner: restrict progress lines to the screen width.
authorAvery Pennarun <apenwarr@gmail.com>
Sun, 20 Feb 2011 04:48:15 +0000 (20:48 -0800)
committerAvery Pennarun <apenwarr@gmail.com>
Sun, 20 Feb 2011 05:38:28 +0000 (21:38 -0800)
Otherwise \r won't work as expected.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/newliner-cmd.py

index 966725e8fe8ac337e8bc00d70f240f6ae54bff1c..68d327b7ee6aaac273f522fcc23bd2c4d36c2ba6 100755 (executable)
@@ -15,6 +15,7 @@ if extra:
 r = re.compile(r'([\r\n])')
 lastlen = 0
 all = ''
+width = options._tty_width() or 78
 while 1:
     l = r.split(all, 1)
     if len(l) <= 1:
@@ -32,6 +33,8 @@ while 1:
     else:
         assert(len(l) == 3)
         (line, splitchar, all) = l
+        if splitchar == '\r':
+            line = line[:width]
         sys.stdout.write('%-*s%s' % (lastlen, line, splitchar))
         if splitchar == '\r':
             lastlen = len(line)