Bug 2541 - pager redirects error messages to stdout and always sets exit code 0
Summary: pager redirects error messages to stdout and always sets exit code 0
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: brodie
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-08 10:17 UTC by Thomas Arendsen Hein
Modified: 2011-03-14 15:00 UTC (History)
5 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Arendsen Hein 2010-12-08 10:17 UTC
Mercurial 1.7.2 (and 1.6 and default):

$ hg --config extensions.pager= cat foobarbaz
yields exit code 0 and appending 2>foo would not write the error message
to file foo

$ hg --config extensions.pager=\! cat foobarbaz
(or just "hg cat foobarbaz" if no pager configured)
does not have above problems.

What should be done here?
Should the pager be used if there is an error?
Comment 1 Matt Mackall 2010-12-08 10:47 UTC
We might not know if there's an error until there's a substantial amount of
output.

We obviously need to fix the return code issue.

We should probably not redirect stderr either, though we should perhaps have
a config setting to allow it.
Comment 2 brodie 2011-01-03 07:23 UTC
We can simply check sys.stderr.isatty() and avoid redirecting it to the pager 
if it returns False.

Since the pager is the parent process, I'm not sure how we can influence its 
return code.

Ideally, the extension would run the pager as a child process and stop 
Mercurial from returning until the pager has returned. I haven't figured out a 
reliable way to do that, though.
Comment 3 HG Bot 2011-03-14 15:00 UTC
Fixed by http://selenic.com/repo/hg/rev/994510694b1d
Brodie Rao <brodie@bitheap.org>
pager: don't page stderr if it's being redirected (issue2541)

(please test the fix)
Comment 4 Bugzilla 2012-05-12 09:15 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:15 EDT  ---

This bug was previously known as _bug_ 2541 at http://mercurial.selenic.com/bts/issue2541