mercurial/ui.py
changeset 31624 c60091fa1426
parent 31592 c5d924e5dfdb
child 31679 0f8ba0bc1154
--- a/mercurial/ui.py	Fri Mar 24 15:05:42 2017 -0700
+++ b/mercurial/ui.py	Fri Mar 24 22:40:08 2017 -0400
@@ -846,15 +846,6 @@
         if not pagercmd:
             return
 
-        if pycompat.osname == 'nt':
-            # `more` cannot be invoked with shell=False, but `more.com` can.
-            # Hide this implementation detail from the user, so we can also get
-            # sane bad PAGER behavior.  If args are also given, the space in the
-            # command line forces shell=True, so that case doesn't need to be
-            # handled here.
-            if pagercmd == 'more':
-                pagercmd = 'more.com'
-
         self.debug('starting pager for command %r\n' % command)
         self.flush()
         self.pageractive = True
@@ -881,6 +872,21 @@
         # simple pager command configurations, we can degrade
         # gracefully and tell the user about their broken pager.
         shell = any(c in command for c in "|&;<>()$`\\\"' \t\n*?[#~=%")
+
+        if pycompat.osname == 'nt' and not shell:
+            # Window's built-in `more` cannot be invoked with shell=False, but
+            # its `more.com` can.  Hide this implementation detail from the
+            # user so we can also get sane bad PAGER behavior.  MSYS has
+            # `more.exe`, so do a cmd.exe style resolution of the executable to
+            # determine which one to use.
+            fullcmd = util.findexe(command)
+            if not fullcmd:
+                self.warn(_("missing pager command '%s', skipping pager\n")
+                          % command)
+                return
+
+            command = fullcmd
+
         try:
             pager = subprocess.Popen(
                 command, shell=shell, bufsize=-1,