From: Johannes Berg Date: Tue, 30 Nov 2021 20:20:53 +0000 (+0100) Subject: main: treat BUP_FORCE_TTY as bitmap X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=0a3058205aadb2dcbdcfde285bbb82c6b48a9742 main: treat BUP_FORCE_TTY as bitmap We treat BUP_FORCE_TTY from the environment as a bitmap all the time, so do the same in main. This requires an update to one of the tests using it, but otherwise it's supposed to be internal API, i.e. not documented in the man page or such. Signed-off-by: Johannes Berg Reviewed-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/main.py b/lib/bup/main.py index dcab41b..4adae0b 100755 --- a/lib/bup/main.py +++ b/lib/bup/main.py @@ -192,9 +192,11 @@ if not cmd_module: already_fixed = int(environ.get(b'BUP_FORCE_TTY', 0)) if subcmd_name in [b'mux', b'ftp', b'help']: - already_fixed = True -fix_stdout = not already_fixed and os.isatty(1) -fix_stderr = not already_fixed and os.isatty(2) + fix_stdout = False + fix_stderr = False +else: + fix_stdout = not (already_fixed & 1) and os.isatty(1) + fix_stderr = not (already_fixed & 2) and os.isatty(2) if fix_stdout or fix_stderr: _ttymask = (fix_stdout and 1 or 0) + (fix_stderr and 2 or 0) diff --git a/test/ext/test-ls b/test/ext/test-ls index 8a93c39..86d8c58 100755 --- a/test/ext/test-ls +++ b/test/ext/test-ls @@ -61,7 +61,7 @@ src_tree_hash=$(git log --format=%T -n1 src) WVSTART "$ls_cmd_desc (short)" -(export BUP_FORCE_TTY=1; WVPASSEQ "$(WVPASS bup-ls | tr -d ' ')" src) +(export BUP_FORCE_TTY=3; WVPASSEQ "$(WVPASS bup-ls | tr -d ' ')" src) WVPASSEQ "$(WVPASS bup-ls /)" "src"