diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-05-06 01:45:19 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-05-06 01:45:19 +0100 |
| commit | a48d2f7a409fcbbeaa93441b99e79b137f211766 (patch) | |
| tree | 6dba386185d1f72d0b7bcaf326923928347760ae | |
| parent | 58a51d76d1935db64e10f6d6c24e94b60307123e (diff) | |
Escape-space fix.
| -rwxr-xr-x | cdist | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -152,6 +152,9 @@ def log(m): if not globals.quiet: print('\x1b[33m* %s\x1b[0m' % m) +def escape_spaces(s): + return s.replace(' ', '\\ ') + def scp_escape(n): """Escape a host:filename string for use with an scp command""" s = n.split(':') @@ -178,8 +181,8 @@ def copyfile(a, b): host = b[:bc] path = b[bc+1:] temp_path = os.path.join(os.path.dirname(path), ".tmp." + os.path.basename(path)) - command('scp %s %s:%s' % (scp_escape(a), host, scp_escape(temp_path))) - command('ssh %s -- mv %s %s' % (host, scp_escape(temp_path), scp_escape(path))) + command('scp %s %s' % (scp_escape(a), scp_escape(host + ":" + temp_path))) + command('ssh %s -- mv "%s" "%s"' % (host, escape_spaces(temp_path), escape_spaces(path))) else: command('scp %s %s' % (scp_escape(a), scp_escape(b))) |
