summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-11-07 23:52:56 +0000
committerCarl Hetherington <cth@carlh.net>2014-11-07 23:52:56 +0000
commit3b6e9a9a43a7267ae33cf1caae77af54ef77b6ad (patch)
tree9d10c42e11e3cd42513824c5a18243dabd478e59
parent88df874df396dce938f32a98791c299166029af4 (diff)
Try again to fix scp escaping.
-rwxr-xr-xcdist13
1 files changed, 11 insertions, 2 deletions
diff --git a/cdist b/cdist
index f0e39e7..2be1b06 100755
--- a/cdist
+++ b/cdist
@@ -112,13 +112,22 @@ def log(m):
if not globals.quiet:
print '\x1b[33m* %s\x1b[0m' % m
+def scp_escape(n):
+ s = n.split(':')
+ assert(len(s) == 1 or len(s) == 2)
+ if len(s) == 2:
+ s[1] = '"\'%s\'"' % s[1]
+ return '%s:%s' % (s[0], s[1])
+ else:
+ return n
+
def copytree(a, b):
log('copy %s -> %s' % (a, b))
- os.system('scp -r "\'%s\'" "\'%s\'"' % (a, b))
+ os.system('scp -r "\'%s\'" "\'%s\'"' % (scp_escape(a), scp_escape(b)))
def copyfile(a, b):
log('copy %s -> %s' % (a, b))
- os.system('scp "\'%s\'" "\'%s\'"' % (a, b))
+ os.system('scp "\'%s\'" "\'%s\'"' % (scp_escape(a), scp_escape(b)))
def rmdir(a):
log('remove %s' % a)