Module | RVM::Shell::Utility |
In: |
lib/rvm/shell/utility.rb
|
From a command, will build up a runnable command. If args isn‘t provided, it will escape arguments.
# File lib/rvm/shell/utility.rb, line 31 def build_cli_call(command, args = nil) "#{command} #{escape_arguments(args)}".strip end
Given a string, converts to the escaped format. This ensures that things such as variables aren‘t evaluated into strings and everything else is setup as expected.
# File lib/rvm/shell/utility.rb, line 17 def escape_argument(s) return "''" if s.empty? s.scan(/('+|[^']+)/).map do |section| section = section.first if section[0] == ?' "\\'" * section.length else "'#{section}'" end end.join end