#!/usr/bin/env ruby #$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib/" require 'readline' RbReadline.rl_completer_quote_characters = "\\" if defined? RbReadline RbReadline.rl_filename_quote_characters = " " if defined? RbReadline module RbReadline # IMPORTANT - this somehow gets changed... @rl_completion_quote_character = "\\" @rl_filename_dequoting_function = :dequote_filename @rl_filename_quoting_function = :quote_filename @rl_char_is_quoted_p = :char_is_quoted? def self.char_is_quoted?(buffer, point) buffer[point-1,1] == "\\" || buffer[point,1] == "\\" end def self.dequote_filename(filename, quote_char) quote_char = "\\" if quote_char == 0.chr filename.delete quote_char # @filename.gsub!(quote_char, "") if @filename end # def self.directory_completion_hook(filename) # @dirname.gsub!("\\", "") if @dirname # end def self.quote_filename(filename, mtype, quote_char) # if mtype == SINGLE_MATCH # @rl_filename_quote_characters.each_char do |c| # filename.sub!(//, "\\#{c}") # end # elsif mtype == MULT_MATCH f = filename.dup @rl_filename_quote_characters.each_char do |c| f.gsub!(c, "\\#{c}") end f # @rl_filename_quote_characters.each_char do |c| # #p c # index = filename.rindex(c) # filename.insert(index, '\\') unless filename[index-1,1] == '\\' # filename.gsub!(//, "\\#{c}") # end # end # filename end end loop do line = Readline::readline('> ') Readline::HISTORY.push(line) puts "You typed: #{line}" break if line == 'quit' end