[BioRuby-cvs] bioruby/lib/bio command.rb,1.10,1.11
Naohisa Goto
ngoto at dev.open-bio.org
Tue May 30 13:59:38 UTC 2006
Update of /home/repository/bioruby/bioruby/lib/bio
In directory dev.open-bio.org:/tmp/cvs-serv29485/lib/bio
Modified Files:
command.rb
Log Message:
Bio::Command::Tools#call_command_local_fork is added, and some messeage are
added.
This is a temporary change.
Bio::Command will be drastically changed later.
Index: command.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/command.rb,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** command.rb 9 May 2006 07:17:11 -0000 1.10
--- command.rb 30 May 2006 13:59:36 -0000 1.11
***************
*** 30,35 ****
UNESCAPABLE_CHARS = /[\x00-\x08\x10-\x1a\x1c-\x1f\x7f\xff]/n
! #module_function
! private
# Escape special characters in command line string for cmd.exe on Windows.
--- 30,34 ----
UNESCAPABLE_CHARS = /[\x00-\x08\x10-\x1a\x1c-\x1f\x7f\xff]/n
! module_function
# Escape special characters in command line string for cmd.exe on Windows.
***************
*** 94,98 ****
call_command_local_popen(cmd, query, &block)
else
! call_command_local_open3(cmd, query, &block)
end
end
--- 93,97 ----
call_command_local_popen(cmd, query, &block)
else
! call_command_local_fork(cmd, query, &block)
end
end
***************
*** 116,119 ****
--- 115,142 ----
end
+ # Executes the program via fork (by using IO.popen("-")) and exec.
+ # If block is given, yield the block with input and output IO objects.
+ #
+ # From the view point of security, this method is recommended
+ # rather than exec_local_popen.
+ def call_command_local_fork(cmd, query = nil)
+ IO.popen("-", "r+") do |io|
+ if io then
+ # parent
+ if block_given?
+ yield io, io
+ else
+ io.sync = true
+ io.print query if query
+ io.close_write
+ io.read
+ end
+ else
+ # child
+ Kernel.exec(*cmd)
+ end
+ end
+ end
+
# Executes the program via Open3.popen3
# If block is given, yield the block with input and output IO objects.
***************
*** 193,197 ****
# (Note that Content-Type and Content-Length are automatically
# set by default.)
! # +uri+ must be a URI object and +params+ must be a hash.
#
def post_form(uri, params, header = {})
--- 216,221 ----
# (Note that Content-Type and Content-Length are automatically
# set by default.)
! # +uri+ must be a URI object, +params+ must be a hash, and
! # +header+ must be a hash.
#
def post_form(uri, params, header = {})
More information about the bioruby-cvs
mailing list