Method: SSHKit::Backend::Abstract#within

Defined in:
lib/sshkit/backends/abstract.rb

#within(directory, &block) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/sshkit/backends/abstract.rb', line 73

def within(directory, &block)
  (@pwd ||= []).push directory.to_s
  execute <<-EOTEST, verbosity: Logger::DEBUG
    if test ! -d #{File.join(@pwd)}
      then echo "Directory does not exist '#{File.join(@pwd)}'" 1>&2
      false
    fi
    EOTEST
    yield
ensure
  @pwd.pop
end