pager: don't page stderr if it's being redirected (
issue2541)
--- a/hgext/pager.py Fri Mar 11 11:14:21 2011 +0100
+++ b/hgext/pager.py Tue Jan 04 00:24:34 2011 +1100
@@ -59,14 +59,17 @@
def _runpager(p):
if not hasattr(os, 'fork'):
- sys.stderr = sys.stdout = util.popen(p, 'wb')
+ sys.stdout = util.popen(p, 'wb')
+ if sys.stderr.isatty():
+ sys.stderr = sys.stdout
return
fdin, fdout = os.pipe()
pid = os.fork()
if pid == 0:
os.close(fdin)
os.dup2(fdout, sys.stdout.fileno())
- os.dup2(fdout, sys.stderr.fileno())
+ if sys.stderr.isatty():
+ os.dup2(fdout, sys.stderr.fileno())
os.close(fdout)
return
os.dup2(fdin, sys.stdin.fileno())