Skip to content

within(dir) fails now when dir is an empty string or nil #476

Description

@mherold

within('') and within(nil) used to work before #453, but now it fails with "Directory does not exist".

I'm not sure whether the new behaviour is intended? It breaks things in other gems which use sshkit, e.g. capistrano-passenger: https://github.com/capistrano/passenger/blob/6dc408ec690d0cbe8c2e9d86c33ad4f7977dfa73/lib/capistrano/tasks/passenger.cap#L13

Example to reproduce:

> require 'sshkit'
> include SSHKit::DSL
> run_locally { within('') { puts(capture(:ls)) } }
SSHKit::Command::Failed (if test ! -d ''; then echo "Directory does not exist ''''" 1>&2; false; fi exit status: 256)
if test ! -d ''; then echo "Directory does not exist ''''" 1>&2; false; fi stdout: Nothing written
if test ! -d ''; then echo "Directory does not exist ''''" 1>&2; false; fi stderr: Directory does not exist ''''

The reason for the behaviour change seems to be that empty strings will also be shellescape'd:

> ''.shellescape
 => "''" 

(within() in /lib/sshkit/backends/abstract.rb)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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