From: Johannes Berg Date: Tue, 30 Nov 2021 20:23:05 +0000 (+0100) Subject: random: use helpers.istty1 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=443ef13d118c8c213bf102b5fe36432df51886a3 random: use helpers.istty1 The helpers.istty1 variable can be used in place of the same conditions open-coded here. Signed-off-by: Johannes Berg Reviewed-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/cmd/random.py b/lib/bup/cmd/random.py index c4b234e..9ad64e4 100755 --- a/lib/bup/cmd/random.py +++ b/lib/bup/cmd/random.py @@ -1,9 +1,9 @@ from __future__ import absolute_import -import os, sys +import sys from bup import options, _helpers -from bup.helpers import handle_ctrl_c, log, parse_num +from bup.helpers import handle_ctrl_c, log, parse_num, istty1 optspec = """ @@ -25,8 +25,7 @@ def main(argv): handle_ctrl_c() - if opt.force or (not os.isatty(1) and - not int(os.environ.get('BUP_FORCE_TTY', 0)) & 1): + if opt.force or not istty1: _helpers.write_random(sys.stdout.fileno(), total, opt.seed, opt.verbose and 1 or 0) else: