Skip to content

Commit

Permalink
Manually sync with ruby/open3#22 and related PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Nov 30, 2023
1 parent 7174c62 commit f2bb539
Showing 1 changed file with 66 additions and 24 deletions.
90 changes: 66 additions & 24 deletions lib/open3.rb
Expand Up @@ -72,11 +72,11 @@
# Each of the methods above accepts:
#
# - An optional hash of environment variable names and values;
# see {Execution Environment}[rdoc-ref:Process#Execution+Environment].
# see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
# - A required string argument that is a +command_line+ or +exe_path+;
# see {Argument command_line or exe_path}[rdoc-ref:Process#Argument+command_line+or+exe_path].
# see {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
# - An optional hash of execution options;
# see {Execution Options}[rdoc-ref:Process#Execution+Options].
# see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
module Open3

Expand Down Expand Up @@ -135,12 +135,17 @@ module Open3
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# Unlike Process.spawn, this method waits for the child process to exit
# before returning, so the caller need not do so.
#
# Argument +options+ is a hash of options for the new process;
# If the first argument is a hash, it becomes leading argument +env+
# in the call to Process.spawn;
# see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
#
# If the last argument is a hash, it becomes trailing argument +options+
# in the call to Process.spawn;
# see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
# The single required argument is one of the following:
Expand Down Expand Up @@ -283,12 +288,17 @@ def popen3(*cmd, &block)
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# Unlike Process.spawn, this method waits for the child process to exit
# before returning, so the caller need not do so.
#
# Argument +options+ is a hash of options for the new process;
# If the first argument is a hash, it becomes leading argument +env+
# in the call to Process.spawn;
# see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
#
# If the last argument is a hash, it becomes trailing argument +options+
# in the call to Process.spawn;
# see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
# The single required argument is one of the following:
Expand Down Expand Up @@ -422,12 +432,17 @@ def popen2(*cmd, &block)
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# Unlike Process.spawn, this method waits for the child process to exit
# before returning, so the caller need not do so.
#
# Argument +options+ is a hash of options for the new process;
# If the first argument is a hash, it becomes leading argument +env+
# in the call to Process.spawn;
# see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
#
# If the last argument is a hash, it becomes trailing argument +options+
# in the call to Process.spawn;
# see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
# The single required argument is one of the following:
Expand Down Expand Up @@ -555,15 +570,20 @@ class << self
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# Unlike Process.spawn, this method waits for the child process to exit
# before returning, so the caller need not do so.
#
# Argument +options+ is a hash of options for the new process;
# If the first argument is a hash, it becomes leading argument +env+
# in the call to Open3.popen3;
# see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
#
# If the last argument is a hash, it becomes trailing argument +options+
# in the call to Open3.popen3;
# see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
# The hash +options+ is passed to method Open3.popen3;
# The hash +options+ is given;
# two options have local effect in method Open3.capture3:
#
# - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
Expand All @@ -572,7 +592,7 @@ class << self
# Open3.capture3('tee', stdin_data: 'Foo')
# # => ["Foo", "", #<Process::Status: pid 2319575 exit 0>]
#
# - If entry <tt>options[:binmode]</tt> exists, the entry is removed
# - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
# the internal streams are set to binary mode.
#
# The single required argument is one of the following:
Expand Down Expand Up @@ -676,15 +696,20 @@ def capture3(*cmd)
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# Unlike Process.spawn, this method waits for the child process to exit
# before returning, so the caller need not do so.
#
# Argument +options+ is a hash of options for the new process;
# If the first argument is a hash, it becomes leading argument +env+
# in the call to Open3.popen3;
# see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
#
# If the last argument is a hash, it becomes trailing argument +options+
# in the call to Open3.popen3;
# see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
# The hash +options+ is passed to method Open3.popen3;
# The hash +options+ is given;
# two options have local effect in method Open3.capture2:
#
# - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
Expand All @@ -694,6 +719,7 @@ def capture3(*cmd)
#
# # => ["Foo", #<Process::Status: pid 2326087 exit 0>]
#
# - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
# the internal streams are set to binary mode.
#
# The single required argument is one of the following:
Expand Down Expand Up @@ -798,15 +824,20 @@ def capture2(*cmd)
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# Unlike Process.spawn, this method waits for the child process to exit
# before returning, so the caller need not do so.
#
# Argument +options+ is a hash of options for the new process;
# If the first argument is a hash, it becomes leading argument +env+
# in the call to Open3.popen3;
# see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
#
# If the last argument is a hash, it becomes trailing argument +options+
# in the call to Open3.popen3;
# see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
# The hash +options+ is passed to method Open3.popen3;
# The hash +options+ is given;
# two options have local effect in method Open3.capture2e:
#
# - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
Expand All @@ -815,6 +846,7 @@ def capture2(*cmd)
# Open3.capture2e('tee', stdin_data: 'Foo')
# # => ["Foo", #<Process::Status: pid 2371732 exit 0>]
#
# - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
# the internal streams are set to binary mode.
#
# The single required argument is one of the following:
Expand Down Expand Up @@ -959,7 +991,7 @@ def capture2e(*cmd)
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# If the first argument is a hash, it becomes leading argument +env+
# in each call to Process.spawn;
Expand All @@ -977,6 +1009,8 @@ def capture2e(*cmd)
# - An array containing a +command_line+ or an +exe_path+,
# along with zero or more string arguments for the command.
#
# See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline_rw(*cmds, &block)
if Hash === cmds.last
opts = cmds.pop.dup
Expand Down Expand Up @@ -1047,7 +1081,7 @@ def pipeline_rw(*cmds, &block)
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# If the first argument is a hash, it becomes leading argument +env+
# in each call to Process.spawn;
Expand All @@ -1065,6 +1099,8 @@ def pipeline_rw(*cmds, &block)
# - An array containing a +command_line+ or an +exe_path+,
# along with zero or more string arguments for the command.
#
# See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline_r(*cmds, &block)
if Hash === cmds.last
opts = cmds.pop.dup
Expand Down Expand Up @@ -1136,7 +1172,7 @@ def pipeline_r(*cmds, &block)
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# If the first argument is a hash, it becomes leading argument +env+
# in each call to Process.spawn;
Expand All @@ -1154,6 +1190,8 @@ def pipeline_r(*cmds, &block)
# - An array containing a +command_line+ or an +exe_path+,
# along with zero or more string arguments for the command.
#
# See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline_w(*cmds, &block)
if Hash === cmds.last
opts = cmds.pop.dup
Expand Down Expand Up @@ -1211,7 +1249,7 @@ def pipeline_w(*cmds, &block)
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# If the first argument is a hash, it becomes leading argument +env+
# in each call to Process.spawn;
Expand All @@ -1229,6 +1267,8 @@ def pipeline_w(*cmds, &block)
# - An array containing a +command_line+ or an +exe_path+,
# along with zero or more string arguments for the command.
#
# See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline_start(*cmds, &block)
if Hash === cmds.last
opts = cmds.pop.dup
Expand Down Expand Up @@ -1271,7 +1311,7 @@ def pipeline_start(*cmds, &block)
#
# Like Process.spawn, this method has potential security vulnerabilities
# if called with untrusted input;
# see {Command Injection}[rdoc-ref:command_injection.rdoc].
# see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
# If the first argument is a hash, it becomes leading argument +env+
# in each call to Process.spawn;
Expand All @@ -1289,6 +1329,8 @@ def pipeline_start(*cmds, &block)
# - An array containing a +command_line+ or an +exe_path+,
# along with zero or more string arguments for the command.
#
# See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline(*cmds)
if Hash === cmds.last
opts = cmds.pop.dup
Expand Down

0 comments on commit f2bb539

Please sign in to comment.