[TxMt] Properly escaping characters in ruby script

Ian Duncan iand675 at gmail.com
Wed Apr 8 17:20:32 UTC 2009


Well I rewrote my little script in Ruby and have had mostly success,  
but I need some help escaping things properly. Here's what I'm having  
trouble with:

#!/usr/bin/env ruby

arg = STDIN.read
arg.chomp!
arg.gsub!('\\', '\\\')
arg.gsub!("\'", '\\\'')
arg.gsub!("\"","\\\"")
arg.gsub!('\`', '\\\`')
system("pointfree \""+arg+"\"")

This is intended to enclose text selected in TextMate in quotation  
marks, and then escape all of the following characters within the the  
quotes, and then use that as the argument to pointfree. What's wrong  
with how I'm doing it?

Sorry for all of the questions,
	Ian



More information about the textmate mailing list