Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

IO#popen accepts a Hash like Process#spawn.

  • Loading branch information...
commit f162836a0a87793defe79ea253354eb9e8cb808a 1 parent ec4c6f7
@ileitch ileitch authored
Showing with 15 additions and 2 deletions.
  1. +7 −0 kernel/common/io19.rb
  2. +8 −2 kernel/common/process19.rb
View
7 kernel/common/io19.rb
@@ -718,6 +718,13 @@ def self.popen(str, mode=undefined, options=undefined)
else
cmd = str
end
+
+ if str.last.kind_of? Hash
+ redirects, options = Rubinius::Spawn.adjust_options(str.pop)
+ Rubinius::Spawn.setup_redirects(redirects)
+ Rubinius::Spawn.setup_options(options)
+ end
+
Process.perform_exec cmd.first, cmd.map(&:to_s)
else
Process.perform_exec "/bin/sh", ["sh", "-c", str]
View
10 kernel/common/process19.rb
@@ -205,7 +205,7 @@ def self.adjust_argv(first, *args)
[prog, argv]
end
- def self.exec(env, prog, argv, redirects, options)
+ def self.setup_redirects(redirects)
redirects.each do |key, val|
key = fd_to_io(key)
@@ -219,9 +219,10 @@ def self.exec(env, prog, argv, redirects, options)
key.reopen(val)
end
end
+ end
+ def self.setup_options(options)
ENV.clear if options[:unsetenv_others]
- ENV.update(env)
if chdir = options[:chdir]
Dir.chdir(chdir)
@@ -235,7 +236,12 @@ def self.exec(env, prog, argv, redirects, options)
if umask = options[:umask]
File.umask(umask)
end
+ end
+ def self.exec(env, prog, argv, redirects, options)
+ setup_redirects(redirects)
+ setup_options(options)
+ ENV.update(env)
Process.perform_exec prog, argv
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.