equal
deleted
inserted
replaced
47 |
47 |
48 To ignore global commands like :hg:`version` or :hg:`help`, you have |
48 To ignore global commands like :hg:`version` or :hg:`help`, you have |
49 to specify them in the global .hgrc |
49 to specify them in the global .hgrc |
50 ''' |
50 ''' |
51 |
51 |
52 import sys, os, signal, shlex |
52 import sys, os, signal, shlex, errno |
53 from mercurial import dispatch, util, extensions |
53 from mercurial import dispatch, util, extensions |
54 |
54 |
55 def _runpager(p): |
55 def _runpager(p): |
56 if not hasattr(os, 'fork'): |
56 if not hasattr(os, 'fork'): |
57 sys.stderr = sys.stdout = util.popen(p, 'wb') |
57 sys.stderr = sys.stdout = util.popen(p, 'wb') |
65 os.close(fdout) |
65 os.close(fdout) |
66 return |
66 return |
67 os.dup2(fdin, sys.stdin.fileno()) |
67 os.dup2(fdin, sys.stdin.fileno()) |
68 os.close(fdin) |
68 os.close(fdin) |
69 os.close(fdout) |
69 os.close(fdout) |
70 args = shlex.split(p) |
70 try: |
71 os.execvp(args[0], args) |
71 os.execvp('/bin/sh', ['/bin/sh', '-c', p]) |
|
72 except OSError, e: |
|
73 if e.errno == errno.ENOENT: |
|
74 # no /bin/sh, try executing the pager directly |
|
75 args = shlex.split(p) |
|
76 os.execvp(args[0], args) |
|
77 else: |
|
78 raise |
72 |
79 |
73 def uisetup(ui): |
80 def uisetup(ui): |
74 def pagecmd(orig, ui, options, cmd, cmdfunc): |
81 def pagecmd(orig, ui, options, cmd, cmdfunc): |
75 p = ui.config("pager", "pager", os.environ.get("PAGER")) |
82 p = ui.config("pager", "pager", os.environ.get("PAGER")) |
76 if p and sys.stdout.isatty() and '--debugger' not in sys.argv: |
83 if p and sys.stdout.isatty() and '--debugger' not in sys.argv: |