# File lib/dragonfly/shell.rb, line 32 def escape_args(args) args.shellsplit.map do |arg| quote arg.gsub(/\\?'/, %('\\'')) end.join(' ') end
# File lib/dragonfly/shell.rb, line 38 def quote(string) q = Dragonfly.running_on_windows? ? '"' : "'" q + string + q end
# File lib/dragonfly/shell.rb, line 28 def raise_shell_command_failed(command) raise CommandFailed, "Command failed (#{command}) with exit status #{$?.exitstatus}" end
# File lib/dragonfly/shell.rb, line 12 def run(command, args="") full_command = "#{command} #{escape_args(args)}" log.debug("Running command: #{full_command}") if log_commands begin result = `#{full_command}` rescue Errno::ENOENT raise_shell_command_failed(full_command) end if $?.exitstatus == 1 throw :unable_to_handle elsif !$?.success? raise_shell_command_failed(full_command) end result end
Generated with the Darkfish Rdoc Generator 2.