Skip to content

put adds unwanted backslash on recursive dir #604

@jaraco

Description

@jaraco

I've created a sample dir tree to put:

mkdir -p home/.ssh
touch home/.ssh/dat

Then create a simple fabric script to put that tree on my remote home dir:

>cat fabfile.py
from fabric.api import run, put

def update_profile():
    put('home/.*', './')
    # Fabric 1.5a ends up creating a folder named "\.ssh"
    run('ls -d *.ssh')

Invoking it produces the following:

> fab -H vdeploy update_profile
[vdeploy] Executing task 'update_profile'
[vdeploy] put: home\.ssh\dat -> ./\.ssh/dat
[vdeploy] run: ls -d *.ssh
[vdeploy] out: \.ssh


Done.
Disconnecting from vdeploy... done.

As you can see, it creates a folder not with the same name as the one on the local file system, but instead prefixes it with a backslash.

My guess the backslash is created because this script is run on Windows and Fabric doesn't recognize the backslash when traversing the path.

If someone familiar with the fabric code base would point me to where this might be occurring, I can probably put together a patch/pull request.

As an aside, it seems to take eight backslashes to remove that one backslash:

run('rm -R \\\\\\\\.ssh')

That is, there's one backslash in the file system, doubled to escape for bash, doubled again to escape for Python. What does the third doubling escape for? If I run it from the bash prompt, I only have to provide two backslashes (i.e. "rm -R \.ssh").

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions