123456789_123456789_123456789_123456789_123456789_

Module: RSpec::Core::ShellEscape Private

Do not use. This module is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: rspec-core/lib/rspec/core/shell_escape.rb

Overview

Deals with the fact that ‘shellwords` only works on POSIX systems.

Constant Summary

Class Attribute Summary

Class Method Summary

Class Attribute Details

.shell_allows_unquoted_ids?Boolean (readonly, mod_func)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shell_escape.rb', line 37

def shell_allows_unquoted_ids?
  # Note: ENV['SHELL'] isn't necessarily the shell the user is currently running.
  # According to http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html:
  # "This variable shall represent a pathname of the user's preferred command language interpreter."
  #
  # It's the best we can easily do, though. We err on the side of safety (quoting
  # the id when not actually needed) so it's not a big deal if the user is actually
  # using a different shell.
  SHELLS_ALLOWING_UNQUOTED_IDS.include?(ENV['SHELL'].to_s.split('/').last)
end

Class Method Details

.conditionally_quote(id) (mod_func)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shell_escape.rb', line 32

def conditionally_quote(id)
  return id if shell_allows_unquoted_ids?
  quote(id)
end

.escape(shell_command) (mod_func) Also known as: #open3_safe_escape

Alias for #quote.

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shell_escape.rb', line 19

alias escape quote

.quote(argument) (mod_func) Also known as: .escape, #open3_safe_escape

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shell_escape.rb', line 8

def quote(argument)
  "'#{argument.to_s.gsub("'", "\\\\'")}'"
end