changeset 38491:72286f9e324f

procutil: add a shim for translating shell commands to native commands
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 28 Jun 2018 22:23:08 -0400
parents 5d88fd1bc2af
children 2394cd58b81f
files mercurial/hook.py mercurial/utils/procutil.py
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hook.py	Sat Jun 16 23:26:40 2018 +0900
+++ b/mercurial/hook.py	Thu Jun 28 22:23:08 2018 -0400
@@ -139,9 +139,7 @@
             v = stringutil.pprint(v)
         env['HG_' + k.upper()] = v
 
-    if pycompat.iswindows:
-        environ = procutil.shellenviron(env)
-        cmd = util.platform.shelltocmdexe(cmd, environ)
+    cmd = procutil.shelltonative(cmd, env)
 
     ui.note(_("running hook %s: %s\n") % (name, cmd))
 
--- a/mercurial/utils/procutil.py	Sat Jun 16 23:26:40 2018 +0900
+++ b/mercurial/utils/procutil.py	Thu Jun 28 22:23:08 2018 -0400
@@ -317,6 +317,13 @@
     env['HG'] = hgexecutable()
     return env
 
+if pycompat.iswindows:
+    def shelltonative(cmd, env):
+        return platform.shelltocmdexe(cmd, shellenviron(env))
+else:
+    def shelltonative(cmd, env):
+        return cmd
+
 def system(cmd, environ=None, cwd=None, out=None):
     '''enhanced shell command execution.
     run with environment maybe modified, maybe in different dir.