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

Comments

@paulc
Copy link

@paulc 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(
@bitprophet bitprophet added this to the 1.14.x / next 1.x bugfix milestone Nov 27, 2018
bitprophet added a commit that referenced this issue Nov 27, 2018
@bitprophet bitprophet closed this Nov 27, 2018
ploxiln added a commit to ploxiln/fab-classic that referenced this issue Nov 27, 2018
ojrac added a commit to demiurgestudios/fabric that referenced this issue Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants