Mercurial > hg
comparison hgext/pager.py @ 13642:994510694b1d stable
pager: don't page stderr if it's being redirected (issue2541)
author | Brodie Rao <brodie@bitheap.org> |
---|---|
date | Tue, 04 Jan 2011 00:24:34 +1100 |
parents | 919c440868d9 |
children | 76f295eaed86 |
comparison
equal
deleted
inserted
replaced
13641:2420cb1ea1d6 | 13642:994510694b1d |
---|---|
57 from mercurial import commands, dispatch, util, extensions | 57 from mercurial import commands, dispatch, util, extensions |
58 from mercurial.i18n import _ | 58 from mercurial.i18n import _ |
59 | 59 |
60 def _runpager(p): | 60 def _runpager(p): |
61 if not hasattr(os, 'fork'): | 61 if not hasattr(os, 'fork'): |
62 sys.stderr = sys.stdout = util.popen(p, 'wb') | 62 sys.stdout = util.popen(p, 'wb') |
63 if sys.stderr.isatty(): | |
64 sys.stderr = sys.stdout | |
63 return | 65 return |
64 fdin, fdout = os.pipe() | 66 fdin, fdout = os.pipe() |
65 pid = os.fork() | 67 pid = os.fork() |
66 if pid == 0: | 68 if pid == 0: |
67 os.close(fdin) | 69 os.close(fdin) |
68 os.dup2(fdout, sys.stdout.fileno()) | 70 os.dup2(fdout, sys.stdout.fileno()) |
69 os.dup2(fdout, sys.stderr.fileno()) | 71 if sys.stderr.isatty(): |
72 os.dup2(fdout, sys.stderr.fileno()) | |
70 os.close(fdout) | 73 os.close(fdout) |
71 return | 74 return |
72 os.dup2(fdin, sys.stdin.fileno()) | 75 os.dup2(fdin, sys.stdin.fileno()) |
73 os.close(fdin) | 76 os.close(fdin) |
74 os.close(fdout) | 77 os.close(fdout) |