If there's no BUP_TTY_WIDTH variable already, then environ.get()
will result in None, which cannot be converted to an integer so
we get 0. Then we pass 0 to the other side in the BUP_TTY_WIDTH
environment variable.
Unfortunately, 0 is a really bad default, since textwrap cannot
work with a width of 0, causing tracebacks such as the one Mark
J Hewitt reported:
https://groups.google.com/g/bup-list/c/rfIw3STN2EY/m/C5Y3UrMIAgAJ
Fix this by not passing it through if there's no good value.
Reported-by: Mark J Hewitt <mjh@idnet.com>
Reported-by: Alexander Barton <alex@barton.de>
Fixes: cd3647c81a25 ("bup: pass TTY width through to sub-command and remote")
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
else:
buglvl = helpers.atoi(environ.get(b'BUP_DEBUG'))
force_tty = helpers.atoi(environ.get(b'BUP_FORCE_TTY'))
- tty_width = helpers.atoi(environ.get(b'BUP_TTY_WIDTH'))
+ tty_width = environ.get(b'BUP_TTY_WIDTH', None)
+ if tty_width is not None:
+ tty_width = b'BUP_TTY_WIDTH=%d' % helpers.atoi(tty_width)
+ else:
+ tty_width = b''
cmd = b"""
- sh -c 'BUP_DEBUG=%d BUP_FORCE_TTY=%d BUP_TTY_WIDTH=%d bup %s'
+ sh -c 'BUP_DEBUG=%d BUP_FORCE_TTY=%d %s bup %s'
""" % (buglvl, force_tty, tty_width, subcmd)
argv = [b'ssh']
if port: