diff --git a/hgext/logtoprocess.py b/hgext/logtoprocess.py --- a/hgext/logtoprocess.py +++ b/hgext/logtoprocess.py @@ -36,6 +36,7 @@ import itertools import os +import shlex import subprocess import sys @@ -58,14 +59,14 @@ DETACHED_PROCESS = 0x00000008 _creationflags = DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP - def runshellcommand(script, env, shell=True): + def runshellcommand(script, env, shell=True, _=False): # we can't use close_fds *and* redirect stdin. I'm not sure that we # need to because the detached process has no console connection. subprocess.Popen( script, shell=shell, env=env, close_fds=True, creationflags=_creationflags) else: - def runshellcommand(script, env, shell=True): + def runshellcommand(script, env, shell=True, parse_script=False): # double-fork to completely detach from the parent process # based on http://code.activestate.com/recipes/278731 pid = os.fork() @@ -78,6 +79,11 @@ newsession = {'preexec_fn': os.setsid} else: newsession = {'start_new_session': True} + + # Try to split the arguments when shell is False + if not shell and parse_script: + script = shlex.split(script) + try: # connect stdin to devnull to make sure the subprocess can't # muck up that stream for mercurial. @@ -125,7 +131,8 @@ msgpairs, optpairs), EVENT=event, HGPID=str(os.getpid())) shell = self.configbool('logtoprocess', 'shell') - runshellcommand(script, env, shell) + parsescript = self.configbool('logtoprocess', 'parsescript') + runshellcommand(script, env, shell, parsescript) return super(logtoprocessui, self).log(event, *msg, **opts) # Replace the class for this instance and all clones created from it: diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -566,6 +566,9 @@ coreconfigitem('logtoprocess', 'develwarn', default=None, ) +coreconfigitem('logtoprocess', 'parsescript', + default=False, +) coreconfigitem('logtoprocess', 'shell', default=True, )