mercurial/posix.py
branchstable
changeset 33657 8cb9e921ef8c
parent 33649 739cc0f9cbb4
child 34146 0fa781320203
--- a/mercurial/posix.py	Mon Jul 31 14:55:11 2017 -0700
+++ b/mercurial/posix.py	Fri Aug 04 23:54:12 2017 -0700
@@ -92,10 +92,13 @@
 def sshargs(sshcmd, host, user, port):
     '''Build argument list for ssh'''
     args = user and ("%s@%s" % (user, host)) or host
-    if '-' in args[:2]:
+    if '-' in args[:1]:
         raise error.Abort(
             _('illegal ssh hostname or username starting with -: %s') % args)
-    return port and ("%s -p %s" % (args, port)) or args
+    args = shellquote(args)
+    if port:
+        args = '-p %s %s' % (shellquote(port), args)
+    return args
 
 def isexec(f):
     """check whether a file is executable"""