Class: Inspec::ShellDetector
- Inherits:
-
Object
- Object
- Inspec::ShellDetector
- Defined in:
- lib/inspec/shell_detector.rb
Overview
ShellDetector attempts to detect the shell the invoking user is running by checking:
- The command of our parent
- The SHELL environment variable
- The shell returned by getpwuid for our process UID
Since none of these methods is fullproof, the detected shell is verified against a list of known shells before being returned to the caller.
Constant Summary collapse
- NOT_DETECTED =
Object.new.freeze
- KNOWN_SHELLS =
%w{bash zsh ksh csh sh fish}.freeze
Instance Method Summary collapse
-
#initialize ⇒ ShellDetector
constructor
A new instance of ShellDetector.
- #shell ⇒ Object
- #shell! ⇒ Object
Constructor Details
#initialize ⇒ ShellDetector
Returns a new instance of ShellDetector.
21 22 23 |
# File 'lib/inspec/shell_detector.rb', line 21 def initialize @shell = NOT_DETECTED end |
Instance Method Details
#shell ⇒ Object
25 26 27 28 |
# File 'lib/inspec/shell_detector.rb', line 25 def shell @shell = detect unless detected?(@shell) @shell end |
#shell! ⇒ Object
30 31 32 |
# File 'lib/inspec/shell_detector.rb', line 30 def shell! @shell = detect end |