From: Suraj Kurapati Date: 2009-02-27T07:05:45+09:00 Subject: Re: shell escape 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? require 'shell' Shell.escape('foo "bar".txt') Shall I file a feature request to ruby-core? -- Posted via http://www.ruby-forum.com/.