lib/fulmar/shell.rb in fulmar-shell-1.8.0 vs lib/fulmar/shell.rb in fulmar-shell-1.8.1

- old
+ new

@@ -1,14 +1,15 @@ require 'open3' +require 'pathname' require 'fulmar/ringbuffer' # This shell is part of the fulmar deployment tools # it can be used stand-alone, though module Fulmar # Implements simple access to shell commands class Shell - VERSION = '1.8.0' + VERSION = '1.8.1' attr_accessor :debug, :last_output, :last_error, :quiet, :strict, :interactive attr_reader :path DEFAULT_BUFFER_SIZE = 1000 @@ -38,15 +39,15 @@ def run(command, options = DEFAULT_OPTIONS) reset_output(@last_output.max_size) command = [command] if command.class == String # is a custom path given? - if options[:in] - # is it absolute? - path = options[:in][0, 1] == '/' ? options[:in] : "#{@path}/#{options[:in]}" - else - path = @path - end + path = if options[:in] + # is it absolute? + (Pathname.new options[:in]).absolute? ? options[:in] : "#{@path}/#{options[:in]}" + else + @path + end options[:error_message] ||= 'Last shell command returned an error.' command.unshift "cd \"#{path}\""