From: Avery Pennarun Date: Sun, 20 Feb 2011 04:48:15 +0000 (-0800) Subject: cmd/newliner: restrict progress lines to the screen width. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=35d4a6a5272c995545df1d6210129d7389505ba0;p=packages%2Fb%2Fbup.git cmd/newliner: restrict progress lines to the screen width. Otherwise \r won't work as expected. Signed-off-by: Avery Pennarun --- diff --git a/cmd/newliner-cmd.py b/cmd/newliner-cmd.py index 966725e..68d327b 100755 --- a/cmd/newliner-cmd.py +++ b/cmd/newliner-cmd.py @@ -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)