Module: Cute::Bash

Defined in:
lib/cute/bash.rb

Defined Under Namespace

Classes: Bash, BashError, BashPaddingError, BashTimeout, StatusError

Class Method Summary collapse

Class Method Details

.bash(cmd = 'bash', debug = false, &block) ⇒ Object



314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/cute/bash.rb', line 314

def self.bash(cmd = 'bash', debug = false, &block)
    if not block_given?
        sin, sout, _serr, _thr = Open3.popen3(cmd)
        return Bash.new(sin, sout, debug)
    end
    # run bash interpreter using this command
    result = nil
    Open3.popen3(cmd) do |cmdsin, cmdsout, _cmdserr, _cmdthr|
        dsl = Bash.new(cmdsin, cmdsout, debug)
        dsl.cd('~')   # go to the home dir
        result = dsl.parse(&block)
    end
    return result
end