Module: Mario::Hats::Nix
- Included in:
- Platform::BSD, Platform::Cygwin, Platform::Darwin, Platform::Linux, Platform::Solaris
- Defined in:
- lib/mario/hats/nix.rb
Instance Method Summary collapse
-
#shell_escape_path(str) ⇒ String
Escapes paths for use in execute statements.
Instance Method Details
#shell_escape_path(str) ⇒ String
Escapes paths for use in execute statements
9 10 11 12 13 14 |
# File 'lib/mario/hats/nix.rb', line 9 def shell_escape_path(str) # Taken from ruby mailing list, seems to work, probably needs lots of testing :( str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/n, '\\'). gsub(/\n/, "'\n'"). sub(/^$/, "''") end |