Class: Rundoc::CodeCommand::BashRunner::Cd
- Inherits:
-
Rundoc::CodeCommand::BashRunner
- Object
- Rundoc::CodeCommand::BashRunner
- Rundoc::CodeCommand::BashRunner::Cd
- Defined in:
- lib/rundoc/code_command/bash/cd.rb
Instance Attribute Summary
Attributes inherited from Rundoc::CodeCommand::BashRunner
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(line, io: $stdout) ⇒ Cd
constructor
A new instance of Cd.
- #suppress_chdir_warning ⇒ Object
Methods inherited from Rundoc::CodeCommand::BashRunner
#raise_on_error?, #sanitize_escape_chars, #shell, #to_md
Constructor Details
#initialize(line, io: $stdout) ⇒ Cd
Returns a new instance of Cd.
5 6 7 8 |
# File 'lib/rundoc/code_command/bash/cd.rb', line 5 def initialize(line, io: $stdout) @io = io @line = line end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rundoc/code_command/bash/cd.rb', line 18 def call(env) line = @line.sub("cd", "").strip @io.puts "running $ cd #{line}" suppress_chdir_warning do Dir.chdir(line) end nil end |
#suppress_chdir_warning ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/rundoc/code_command/bash/cd.rb', line 10 def suppress_chdir_warning old_verbose = $VERBOSE $VERBOSE = nil yield ensure $VERBOSE = old_verbose end |