Commits

Yuya Nishihara committed 8e5db5f

openshell: parse command string by shlex.split()

Because QProcess.startDetached(program) does not support single quotes,
it fails to spawn `'/usr/bin/xterm' -T "thg"` for example.

Comments (0)

Files changed (1)

tortoisehg/hgqt/qtlib.py

 import sys
 import atexit
 import shutil
+import shlex
 import stat
 import subprocess
 import tempfile
             if args:
                 shell = shell + ' ' + util.expandpath(args)
             shellcmd = shell % {'root': root, 'reponame': reponame}
+
+            # Unix: QProcess.startDetached(program) cannot parse single-quoted
+            # parameters built using util.shellquote().
+            # Windows: subprocess.Popen(program, shell=True) cannot spawn
+            # cmd.exe in new window, probably because the initial cmd.exe is
+            # invoked with SW_HIDE.
             os.chdir(root)
-            started = QProcess.startDetached(shellcmd)
+            fullargs = shlex.split(shellcmd)
+            started = QProcess.startDetached(fullargs[0], fullargs[1:])
         finally:
             os.chdir(cwd)
         if not started: