Error running update on remote path containing a space

Bug #215127 reported by Mark Patterson
2
Affects Status Importance Assigned to Milestone
Plugin to Update Remote Trees
Medium
Mark Patterson

Bug Description

For example:

$ bzr push
Using saved location: sftp://talisker3/home/mark/Matlab Utilities/
running "ssh talisker3 bzr update /home/mark/Matlab Utilities/"
bzr: ERROR: extra argument to command update: Utilities/
No new revisions to push.

I believe the solution is just to wrap the path in quotes when sending it over ssh:
=== modified file 'push_and_update.py'
--- push_and_update.py 2007-12-14 22:41:55 +0000
+++ push_and_update.py 2008-04-10 13:33:42 +0000
@@ -145,6 +145,7 @@

     if path.startswith('/~/'):
         path = path[3:] # This is meant to be a relative path
+ path = '"%s"' % (path,) # Wrap the path in quotes in case it contains spaces

     remote_bzr = target_branch.get_config().get_bzr_remote_path()
     cmd = ['ssh', user+host+port, remote_bzr, 'update', path]

Related branches

Revision history for this message
John A Meinel (jameinel) wrote :

This seems to be an interaction between ssh and parameters passed to it. By using a list, we are properly passing it as a single argument, but then ssh passes it to the next shell as a plain string.

It happens on the command line as well:
ssh juju python -c "import sys; print sys.argv" fo bar bar
sys.argv fo bar bar
  File "<string>", line 1
    import
         ^
SyntaxError: invalid syntax

versus:
ssh juju python -c "'import sys; print sys.argv'" fo bar bar
['-c', 'fo', 'bar', 'bar']

I wish there was a better way, since this would have problems if there was a ", etc. But I guess as a workaround for how ssh invokes the remote shell, it is all we can really do. I'll merge it.

Revision history for this message
John A Meinel (jameinel) wrote :

A slightly modified version of your patch has been applied and committed to trunk.

Changed in bzr-push-and-update:
assignee: nobody → cleobis
importance: Undecided → Medium
status: New → Fix Released
Revision history for this message
mestre.adamastor (mestre.adamastor) wrote :

On a Windows machine, this plugin did not work because bash would not understand the double quotes.
I could solve the problem by swapping " by ' in a specific line.
It now works nicely on the Windows machine, here is a diff.

=== modified file push_and_update.py
--- push_and_update.py 2008-04-17 21:17:26 +0000
+++ push_and_update.py 2009-12-28 12:36:14 +0000
@@ -149,7 +149,7 @@
     remote_bzr = target_branch.get_config().get_bzr_remote_path()
     # The path needs to be double escaped. We pass it to ssh as a single
     # argument, but ssh passes it to the child shell as a whole string.
- path = '"%s"' % (path,)
+ path = "'%s'" % (path,)
     cmd = ['ssh', user+host+port, remote_bzr, 'update', path]
     print 'running "%s"' % (' '.join(cmd))

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers