Merge.
authorCarl Hetherington <cth@carlh.net>
Sun, 6 May 2018 00:46:02 +0000 (01:46 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 6 May 2018 00:46:02 +0000 (01:46 +0100)
1  2 
cdist

diff --combined cdist
index fc4e47891731dd4ec78558f935706cdb7f7f21d6,44978d5dc126ae0d67a02bd3d5e4c39f19582f3b..ccbcff8aad77e384e1263e8d6393c2be20b0b7c8
--- 1/cdist
--- 2/cdist
+++ b/cdist
@@@ -152,9 -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(':')
      else:
          return '\"%s\"' % s[0]
  
+ def mv_escape(n):
+     return '\"%s\"' % n.substr(' ', '\\ ')
  def copytree(a, b):
      log('copy %s -> %s' % (scp_escape(a), scp_escape(b)))
      if b.startswith('s3://'):
@@@ -181,8 -181,8 +184,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' % (scp_escape(a), scp_escape('%s:%s' % (host, temp_path))))
 -            command('ssh %s -- mv %s %s' % (host, mv_escape(temp_path), mv_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)))