shellescape(str) public

Escapes a string so that it can be safely used in a Bourne shell command line.

Note that a resulted string should be used unquoted and is not intended for use in double quotes nor in single quotes.

  open("| grep #{Shellwords.escape(pattern)} file") { |pipe|
    # ...
  }

+String#shellescape+ is a shorthand for this function.

  open("| grep #{pattern.shellescape} file") { |pipe|
    # ...
  }
Show source
Register or log in to add new notes.