From: James Gray Date: 2009-02-27T07:11:04+09:00 Subject: Re: shell escape On Feb 26, 2009, at 4:05 PM, Suraj Kurapati wrote: > James Gray wrote: >> I would define shell_escape() as something like: >> >> def shell_escape(str) >> String(str).gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/n, '\\'). >> gsub(/\n/, "'\n'"). >> sub(/^$/, "''") >> end >> > > Nice! I always wished this method was in the Ruby stdlib. Maybe it > could be added as a class method of the Shell class in the "shell" > stdlib? It's in Ruby 1.9. See my notes at the bottom of this post: http://blog.grayproductions.net/articles/the_secret_shell_helper James Edward Gray II