From 8f82a4f828c2765cc4585f9d749f5155f06fd9e9 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 1 Apr 2009 07:24:22 -0700 Subject: Don't start the pager if stdout is a pipe The repo script often uses a pager by default and will produce control characters (coloring) to standard output when using the pager, even if the output is redirected to another pipe or script. This is because the pager setup checked for the terminal presence on FD 0, and in case of redirection FD 0 is still attached to the terminal. Instead require that both FD 0 and FD 1 are connected to the terminal in order to start the pager. Bug: REPO-19, b.android.com/2004 Signed-off-by: Shawn O. Pearce --- pager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pager.py') diff --git a/pager.py b/pager.py index 320131cd..714c3db5 100755 --- a/pager.py +++ b/pager.py @@ -22,7 +22,7 @@ active = False def RunPager(globalConfig): global active - if not os.isatty(0): + if not os.isatty(0) or not os.isatty(1): return pager = _SelectPager(globalConfig) if pager == '' or pager == 'cat': -- cgit v1.2.3-54-g00ecf