Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fabric.contrib.files.upload_template backup fails if env.shell does not support brace expansion (eg. /bin/sh) - Patch included #1227

Closed
paulc opened this issue Dec 7, 2014 · 0 comments · Fixed by ploxiln/fab-classic#8

Comments

@paulc
Copy link

paulc commented Dec 7, 2014

fabric.contrib.files.upload_template relies on brace expansion to create the backup file - eg.

cp "$(echo report.txt)"{,.bak}

This fails if env.shell does not support brace expansion (which is true for /bin/sh).

The following patch fixes the issue.

diff --git a/fabric/contrib/files.py b/fabric/contrib/files.py
index 5db5b31..ef2515f 100644
--- a/fabric/contrib/files.py
+++ b/fabric/contrib/files.py
@@ -150,7 +150,9 @@ def upload_template(filename, destination, context=None, use

     # Back up original file
     if backup and exists(destination):
-        func("cp %s{,.bak}" % _expand_path(destination))
+        orig = _expand_path(destination)
+        bak = _expand_path(destination + ".bak")
+        func("cp %s %s" % (orig,bak))

     # Upload the file.
     return put(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants