Class String
In: util/string.rb
Parent: Object

Extensions to String class:

Methods
shellquote    shellquote!    stripquotes    stripquotes!   
Public Instance methods
shellquote()

Backslash all non-identifier chars in string.

# File util/string.rb, line 48
  def shellquote()
    gsub(/\W/) { |s| "\\"+s }
  end
shellquote!()

shellquote in place

# File util/string.rb, line 52
  def shellquote!()
    replace(shellquote())
  end
stripquotes()

Remove a layer of single or double quotes if not backslashed.

# File util/string.rb, line 57
  def stripquotes()
    # 2 "'s for editors that string-close
    if }^(["'"])(.*)(\1)$} =~ self
      $2
    elsif }^\\(["'"])(.*)(\1)$} =~ self
      $1 + $2 + $3
    else
      self
    end
  end
stripquotes!()

stripquotes in place

# File util/string.rb, line 68
  def stripquotes!()
    replace(stripquotes(q))
  end