]> arthur.barton.de Git - bup.git/blobdiff - cmd/newliner-cmd.py
Set pipefail so that "x | y || exit $?" will work properly.
[bup.git] / cmd / newliner-cmd.py
index 90f88d8629845b92c86f6f4f9d0b30d463a75e78..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,7 +33,8 @@ while 1:
     else:
         assert(len(l) == 3)
         (line, splitchar, all) = l
-        #splitchar = '\n'
+        if splitchar == '\r':
+            line = line[:width]
         sys.stdout.write('%-*s%s' % (lastlen, line, splitchar))
         if splitchar == '\r':
             lastlen = len(line)
@@ -40,5 +42,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)