Skip to content

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

Closed
ploxiln/fab-classic
#8
@paulc

Description

@paulc

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(

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions