[PATCH] ssh: use shlex to parse command line

Steve Borho steve at borho.org
Thu Sep 6 21:57:13 CDT 2007


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1189133805 18000
# Node ID 4618e182d66e753c933572ac54e32d78fd0ebe13
# Parent  a32a8e50d233556d76e12890079af0bf5e07fa23
ssh: use shlex to parse command line
This version passes test-init on Linux

diff -r a32a8e50d233 -r 4618e182d66e mercurial/sshrepo.py
--- a/mercurial/sshrepo.py	Fri Aug 31 23:15:44 2007 +0200
+++ b/mercurial/sshrepo.py	Thu Sep 06 21:56:45 2007 -0500
@@ -8,7 +8,7 @@ from node import *
 from node import *
 from remoterepo import *
 from i18n import _
-import repo, os, re, stat, util
+import repo, os, re, shlex, stat, util
 
 class sshrepository(remoterepository):
     def __init__(self, ui, path, create=0):
@@ -35,8 +35,10 @@ class sshrepository(remoterepository):
             cmd = cmd % (sshcmd, args, remotecmd, self.path)
 
             ui.note('running %s\n' % cmd)
-            res = os.system(cmd)
-            if res != 0:
+            vargs = shlex.split(cmd)
+            cmd = util.find_exe(vargs[0], vargs[0])
+            ret = os.spawnv(os.P_WAIT, cmd, vargs)
+            if ret != 0:
                 self.raise_(repo.RepoError(_("could not create remote repo")))
 
         self.validate_repo(ui, sshcmd, args, remotecmd)
@@ -52,7 +54,7 @@ class sshrepository(remoterepository):
         cmd = cmd % (sshcmd, args, remotecmd, self.path)
 
         ui.note('running %s\n' % cmd)
-        self.pipeo, self.pipei, self.pipee = os.popen3(cmd, 'b')
+        self.pipeo, self.pipei, self.pipee = os.popen3(shlex.split(cmd), 'b')
 
         # skip any noise generated by remote shell
         self.do_cmd("hello")


More information about the Mercurial-devel mailing list