Module: RSpec::Core::ShellEscape
- Included in:
- Bisect::ShellCommand, Notifications::SummaryNotification, RakeTask
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/shell_escape.rb
Overview
Deals with the fact that ‘shellwords` only works on POSIX systems.
Constant Summary collapse
- SHELLS_ALLOWING_UNQUOTED_IDS =
Known shells that require quoting: zsh, csh, tcsh.
Feel free to add other shells to this list that are known to allow ‘rspec ./some_spec.rb` syntax without quoting the id.
%w[ bash ksh fish ]
Class Method Summary collapse
Class Method Details
.conditionally_quote(id) ⇒ Object
32 33 34 35 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/shell_escape.rb', line 32 def conditionally_quote(id) return id if shell_allows_unquoted_ids? quote(id) end |
.quote(argument) ⇒ Object
8 9 10 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/shell_escape.rb', line 8 def quote(argument) "'#{argument.to_s.gsub("'", "\\\\'")}'" end |
.shell_allows_unquoted_ids? ⇒ Boolean
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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 |