changeset 11240:ccb4057e19e6 stable

pager: exec pager using /bin/sh -c This mimics the behavior of popen() and ensures setting the pager to something like "LESS=FSRX less" will work.
author Brodie Rao <brodie@bitheap.org>
date Wed, 19 May 2010 09:54:12 -0500
parents 99bc18d1ab0f
children 258c98567aff 8f5ad12db28e
files hgext/pager.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/pager.py	Fri May 14 12:57:24 2010 -0500
+++ b/hgext/pager.py	Wed May 19 09:54:12 2010 -0500
@@ -49,7 +49,7 @@
 specify them in the global .hgrc
 '''
 
-import sys, os, signal, shlex
+import sys, os, signal, shlex, errno
 from mercurial import dispatch, util, extensions
 
 def _runpager(p):
@@ -67,8 +67,15 @@
     os.dup2(fdin, sys.stdin.fileno())
     os.close(fdin)
     os.close(fdout)
-    args = shlex.split(p)
-    os.execvp(args[0], args)
+    try:
+        os.execvp('/bin/sh', ['/bin/sh', '-c', p])
+    except OSError, e:
+        if e.errno == errno.ENOENT:
+            # no /bin/sh, try executing the pager directly
+            args = shlex.split(p)
+            os.execvp(args[0], args)
+        else:
+            raise
 
 def uisetup(ui):
     def pagecmd(orig, ui, options, cmd, cmdfunc):