Method: Bio::Command.call_command_popen
- Defined in:
- lib/bio/command.rb
.call_command_popen(cmd, options = {}) ⇒ Object
Executes the program via IO.popen for OS which doesn’t support fork. A block must be given. An IO object is passed to the block.
Arguments:
-
(required) cmd: Array containing String objects
-
(optional) options: Hash
- Returns
-
(undefined)
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/bio/command.rb', line 161 def call_command_popen(cmd, = {}) str = make_command_line(cmd) # processing options if dir = [:chdir] then case RUBY_PLATFORM when /mswin32|bccwin32/ # Unix-like dir separator is changed to Windows dir separator # by using String#gsub. dirstr = dir.gsub(/\//, "\\") chdirstr = make_command_line([ 'cd', '/D', dirstr ]) str = chdirstr + ' && ' + str else # UNIX shell chdirstr = make_command_line([ 'cd', dir ]) str = chdirstr + ' && ' + str end end # call command by using IO.popen IO.popen(str, "w+") do |io| io.sync = true yield io end end |