open3 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/open3/version.rb +1 -1
- data/lib/open3.rb +405 -187
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 627e2ba8abf0e5093f8e5188915236d4bc2becb3041a8356025ab9872d4038e1
         | 
| 4 | 
            +
              data.tar.gz: dc4e1a4027f17bd9a4fbb1e7d7c85521679553af87127561ff2f72a02a4fdd30
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 5cff7891c4d3edb418dd973c2dff88cd2ca8e69708658dbecef260c5133081ed4e4cd6ed499f05b0b38ee0430fadecafd71ee7e4f71f6af87f63ff64b30a4a15
         | 
| 7 | 
            +
              data.tar.gz: 0f3db4c91d7d1fb56fa4ae6d0a2ee83a7d298350378bf9e218f15ed7cb112a7db4ce9993a6f41e304ae5b7f867714bc1d6119b3b9e50a1db2e81ae5ccca2e2df
         | 
    
        data/lib/open3/version.rb
    CHANGED
    
    
    
        data/lib/open3.rb
    CHANGED
    
    | @@ -31,6 +31,53 @@ | |
| 31 31 |  | 
| 32 32 | 
             
            require 'open3/version'
         | 
| 33 33 |  | 
| 34 | 
            +
            # \Module \Open3 supports creating child processes
         | 
| 35 | 
            +
            # with access to their $stdin, $stdout, and $stderr streams.
         | 
| 36 | 
            +
            #
         | 
| 37 | 
            +
            # == What's Here
         | 
| 38 | 
            +
            #
         | 
| 39 | 
            +
            # Each of these methods executes a given command in a new process or subshell,
         | 
| 40 | 
            +
            # or multiple commands in new processes and/or subshells:
         | 
| 41 | 
            +
            #
         | 
| 42 | 
            +
            # - Each of these methods executes a single command in a process or subshell,
         | 
| 43 | 
            +
            #   accepts a string for input to $stdin,
         | 
| 44 | 
            +
            #   and returns string output from $stdout, $stderr, or both:
         | 
| 45 | 
            +
            #
         | 
| 46 | 
            +
            #   - Open3.capture2: Executes the command;
         | 
| 47 | 
            +
            #     returns the string from $stdout.
         | 
| 48 | 
            +
            #   - Open3.capture2e: Executes the command;
         | 
| 49 | 
            +
            #     returns the string from merged $stdout and $stderr.
         | 
| 50 | 
            +
            #   - Open3.capture3: Executes the command;
         | 
| 51 | 
            +
            #     returns strings from $stdout and $stderr.
         | 
| 52 | 
            +
            #
         | 
| 53 | 
            +
            # - Each of these methods executes a single command in a process or subshell,
         | 
| 54 | 
            +
            #   and returns pipes for $stdin, $stdout, and/or $stderr:
         | 
| 55 | 
            +
            #
         | 
| 56 | 
            +
            #   - Open3.popen2: Executes the command;
         | 
| 57 | 
            +
            #     returns pipes for $stdin and $stdout.
         | 
| 58 | 
            +
            #   - Open3.popen2e: Executes the command;
         | 
| 59 | 
            +
            #     returns pipes for $stdin and merged $stdout and $stderr.
         | 
| 60 | 
            +
            #   - Open3.popen3: Executes the command;
         | 
| 61 | 
            +
            #     returns pipes for $stdin, $stdout, and $stderr.
         | 
| 62 | 
            +
            #
         | 
| 63 | 
            +
            # - Each of these methods executes one or more commands in processes and/or subshells,
         | 
| 64 | 
            +
            #   returns pipes for the first $stdin, the last $stdout, or both:
         | 
| 65 | 
            +
            #
         | 
| 66 | 
            +
            #   - Open3.pipeline_r: Returns a pipe for the last $stdout.
         | 
| 67 | 
            +
            #   - Open3.pipeline_rw: Returns pipes for the first $stdin and the last $stdout.
         | 
| 68 | 
            +
            #   - Open3.pipeline_w: Returns a pipe for the first $stdin.
         | 
| 69 | 
            +
            #   - Open3.pipeline_start: Does not wait for processes to complete.
         | 
| 70 | 
            +
            #   - Open3.pipeline: Waits for processes to complete.
         | 
| 71 | 
            +
            #
         | 
| 72 | 
            +
            # Each of the methods above accepts:
         | 
| 73 | 
            +
            #
         | 
| 74 | 
            +
            # - An optional hash of environment variable names and values;
         | 
| 75 | 
            +
            #   see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 76 | 
            +
            # - A required string argument that is a +command_line+ or +exe_path+;
         | 
| 77 | 
            +
            #   see {Argument command_line or exe_path}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Argument+command_line+or+exe_path].
         | 
| 78 | 
            +
            # - An optional hash of execution options;
         | 
| 79 | 
            +
            #   see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 80 | 
            +
            #
         | 
| 34 81 | 
             
            module Open3
         | 
| 35 82 |  | 
| 36 83 | 
             
              # :call-seq:
         | 
| @@ -39,7 +86,9 @@ module Open3 | |
| 39 86 | 
             
              #   Open3.popen3([env, ] command_line, options = {}) {|stdin, stdout, stderr, wait_thread| ... } -> object
         | 
| 40 87 | 
             
              #   Open3.popen3([env, ] exe_path, *args, options = {}) {|stdin, stdout, stderr, wait_thread| ... } -> object
         | 
| 41 88 | 
             
              #
         | 
| 42 | 
            -
              # Basically a wrapper for | 
| 89 | 
            +
              # Basically a wrapper for
         | 
| 90 | 
            +
              # {Process.spawn}[https://docs.ruby-lang.org/en/master/Process.html#method-c-spawn]
         | 
| 91 | 
            +
              # that:
         | 
| 43 92 | 
             
              #
         | 
| 44 93 | 
             
              # - Creates a child process, by calling Process.spawn with the given arguments.
         | 
| 45 94 | 
             
              # - Creates streams +stdin+, +stdout+, and +stderr+,
         | 
| @@ -86,13 +135,18 @@ module Open3 | |
| 86 135 | 
             
              #
         | 
| 87 136 | 
             
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 88 137 | 
             
              # if called with untrusted input;
         | 
| 89 | 
            -
              # see {Command Injection}[ | 
| 138 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 90 139 | 
             
              #
         | 
| 91 140 | 
             
              # Unlike Process.spawn, this method waits for the child process to exit
         | 
| 92 141 | 
             
              # before returning, so the caller need not do so.
         | 
| 93 142 | 
             
              #
         | 
| 94 | 
            -
              #  | 
| 95 | 
            -
              #  | 
| 143 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 144 | 
            +
              # in the call to Process.spawn;
         | 
| 145 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 146 | 
            +
              #
         | 
| 147 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 148 | 
            +
              # in the call to Process.spawn;
         | 
| 149 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 96 150 | 
             
              #
         | 
| 97 151 | 
             
              # The single required argument is one of the following:
         | 
| 98 152 | 
             
              #
         | 
| @@ -188,7 +242,9 @@ module Open3 | |
| 188 242 | 
             
              #   Open3.popen2([env, ] command_line, options = {}) {|stdin, stdout, wait_thread| ... } -> object
         | 
| 189 243 | 
             
              #   Open3.popen2([env, ] exe_path, *args, options = {}) {|stdin, stdout, wait_thread| ... } -> object
         | 
| 190 244 | 
             
              #
         | 
| 191 | 
            -
              # Basically a wrapper for | 
| 245 | 
            +
              # Basically a wrapper for
         | 
| 246 | 
            +
              # {Process.spawn}[https://docs.ruby-lang.org/en/master/Process.html#method-c-spawn]
         | 
| 247 | 
            +
              # that:
         | 
| 192 248 | 
             
              #
         | 
| 193 249 | 
             
              # - Creates a child process, by calling Process.spawn with the given arguments.
         | 
| 194 250 | 
             
              # - Creates streams +stdin+ and +stdout+,
         | 
| @@ -232,13 +288,18 @@ module Open3 | |
| 232 288 | 
             
              #
         | 
| 233 289 | 
             
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 234 290 | 
             
              # if called with untrusted input;
         | 
| 235 | 
            -
              # see {Command Injection}[ | 
| 291 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 236 292 | 
             
              #
         | 
| 237 293 | 
             
              # Unlike Process.spawn, this method waits for the child process to exit
         | 
| 238 294 | 
             
              # before returning, so the caller need not do so.
         | 
| 239 295 | 
             
              #
         | 
| 240 | 
            -
              #  | 
| 241 | 
            -
              #  | 
| 296 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 297 | 
            +
              # in the call to Process.spawn;
         | 
| 298 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 299 | 
            +
              #
         | 
| 300 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 301 | 
            +
              # in the call to Process.spawn;
         | 
| 302 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 242 303 | 
             
              #
         | 
| 243 304 | 
             
              # The single required argument is one of the following:
         | 
| 244 305 | 
             
              #
         | 
| @@ -325,7 +386,9 @@ module Open3 | |
| 325 386 | 
             
              #   Open3.popen2e([env, ] command_line, options = {}) {|stdin, stdout_and_stderr, wait_thread| ... } -> object
         | 
| 326 387 | 
             
              #   Open3.popen2e([env, ] exe_path, *args, options = {}) {|stdin, stdout_and_stderr, wait_thread| ... } -> object
         | 
| 327 388 | 
             
              #
         | 
| 328 | 
            -
              # Basically a wrapper for | 
| 389 | 
            +
              # Basically a wrapper for
         | 
| 390 | 
            +
              # {Process.spawn}[https://docs.ruby-lang.org/en/master/Process.html#method-c-spawn]
         | 
| 391 | 
            +
              # that:
         | 
| 329 392 | 
             
              #
         | 
| 330 393 | 
             
              # - Creates a child process, by calling Process.spawn with the given arguments.
         | 
| 331 394 | 
             
              # - Creates streams +stdin+, +stdout_and_stderr+,
         | 
| @@ -369,13 +432,18 @@ module Open3 | |
| 369 432 | 
             
              #
         | 
| 370 433 | 
             
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 371 434 | 
             
              # if called with untrusted input;
         | 
| 372 | 
            -
              # see {Command Injection}[ | 
| 435 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 373 436 | 
             
              #
         | 
| 374 437 | 
             
              # Unlike Process.spawn, this method waits for the child process to exit
         | 
| 375 438 | 
             
              # before returning, so the caller need not do so.
         | 
| 376 439 | 
             
              #
         | 
| 377 | 
            -
              #  | 
| 378 | 
            -
              #  | 
| 440 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 441 | 
            +
              # in the call to Process.spawn;
         | 
| 442 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 443 | 
            +
              #
         | 
| 444 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 445 | 
            +
              # in the call to Process.spawn;
         | 
| 446 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 379 447 | 
             
              #
         | 
| 380 448 | 
             
              # The single required argument is one of the following:
         | 
| 381 449 | 
             
              #
         | 
| @@ -502,15 +570,20 @@ module Open3 | |
| 502 570 | 
             
              #
         | 
| 503 571 | 
             
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 504 572 | 
             
              # if called with untrusted input;
         | 
| 505 | 
            -
              # see {Command Injection}[ | 
| 573 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 506 574 | 
             
              #
         | 
| 507 575 | 
             
              # Unlike Process.spawn, this method waits for the child process to exit
         | 
| 508 576 | 
             
              # before returning, so the caller need not do so.
         | 
| 509 577 | 
             
              #
         | 
| 510 | 
            -
              #  | 
| 511 | 
            -
              #  | 
| 578 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 579 | 
            +
              # in the call to Open3.popen3;
         | 
| 580 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 512 581 | 
             
              #
         | 
| 513 | 
            -
              #  | 
| 582 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 583 | 
            +
              # in the call to Open3.popen3;
         | 
| 584 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 585 | 
            +
              #
         | 
| 586 | 
            +
              # The hash +options+ is given;
         | 
| 514 587 | 
             
              # two options have local effect in method Open3.capture3:
         | 
| 515 588 | 
             
              #
         | 
| 516 589 | 
             
              # - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
         | 
| @@ -519,7 +592,7 @@ module Open3 | |
| 519 592 | 
             
              #     Open3.capture3('tee', stdin_data: 'Foo')
         | 
| 520 593 | 
             
              #     # => ["Foo", "", #<Process::Status: pid 2319575 exit 0>]
         | 
| 521 594 | 
             
              #
         | 
| 522 | 
            -
              # - If entry <tt>options[:binmode]</tt> exists, the entry is removed
         | 
| 595 | 
            +
              # - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
         | 
| 523 596 | 
             
              #   the internal streams are set to binary mode.
         | 
| 524 597 | 
             
              #
         | 
| 525 598 | 
             
              # The single required argument is one of the following:
         | 
| @@ -623,15 +696,20 @@ module Open3 | |
| 623 696 | 
             
              #
         | 
| 624 697 | 
             
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 625 698 | 
             
              # if called with untrusted input;
         | 
| 626 | 
            -
              # see {Command Injection}[ | 
| 699 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 627 700 | 
             
              #
         | 
| 628 701 | 
             
              # Unlike Process.spawn, this method waits for the child process to exit
         | 
| 629 702 | 
             
              # before returning, so the caller need not do so.
         | 
| 630 703 | 
             
              #
         | 
| 631 | 
            -
              #  | 
| 632 | 
            -
              #  | 
| 704 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 705 | 
            +
              # in the call to Open3.popen3;
         | 
| 706 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 707 | 
            +
              #
         | 
| 708 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 709 | 
            +
              # in the call to Open3.popen3;
         | 
| 710 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 633 711 | 
             
              #
         | 
| 634 | 
            -
              # The hash +options+ is  | 
| 712 | 
            +
              # The hash +options+ is given;
         | 
| 635 713 | 
             
              # two options have local effect in method Open3.capture2:
         | 
| 636 714 | 
             
              #
         | 
| 637 715 | 
             
              # - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
         | 
| @@ -641,6 +719,7 @@ module Open3 | |
| 641 719 | 
             
              #
         | 
| 642 720 | 
             
              #     # => ["Foo", #<Process::Status: pid 2326087 exit 0>]
         | 
| 643 721 | 
             
              #
         | 
| 722 | 
            +
              # - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
         | 
| 644 723 | 
             
              #   the internal streams are set to binary mode.
         | 
| 645 724 | 
             
              #
         | 
| 646 725 | 
             
              # The single required argument is one of the following:
         | 
| @@ -745,15 +824,20 @@ module Open3 | |
| 745 824 | 
             
              #
         | 
| 746 825 | 
             
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 747 826 | 
             
              # if called with untrusted input;
         | 
| 748 | 
            -
              # see {Command Injection}[ | 
| 827 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 749 828 | 
             
              #
         | 
| 750 829 | 
             
              # Unlike Process.spawn, this method waits for the child process to exit
         | 
| 751 830 | 
             
              # before returning, so the caller need not do so.
         | 
| 752 831 | 
             
              #
         | 
| 753 | 
            -
              #  | 
| 754 | 
            -
              #  | 
| 832 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 833 | 
            +
              # in the call to Open3.popen3;
         | 
| 834 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 755 835 | 
             
              #
         | 
| 756 | 
            -
              #  | 
| 836 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 837 | 
            +
              # in the call to Open3.popen3;
         | 
| 838 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 839 | 
            +
              #
         | 
| 840 | 
            +
              # The hash +options+ is given;
         | 
| 757 841 | 
             
              # two options have local effect in method Open3.capture2e:
         | 
| 758 842 | 
             
              #
         | 
| 759 843 | 
             
              # - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
         | 
| @@ -762,6 +846,7 @@ module Open3 | |
| 762 846 | 
             
              #     Open3.capture2e('tee', stdin_data: 'Foo')
         | 
| 763 847 | 
             
              #     # => ["Foo", #<Process::Status: pid 2371732 exit 0>]
         | 
| 764 848 | 
             
              #
         | 
| 849 | 
            +
              # - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
         | 
| 765 850 | 
             
              #   the internal streams are set to binary mode.
         | 
| 766 851 | 
             
              #
         | 
| 767 852 | 
             
              # The single required argument is one of the following:
         | 
| @@ -846,48 +931,86 @@ module Open3 | |
| 846 931 | 
             
              end
         | 
| 847 932 | 
             
              module_function :capture2e
         | 
| 848 933 |  | 
| 849 | 
            -
              #  | 
| 850 | 
            -
              #  | 
| 851 | 
            -
              #
         | 
| 852 | 
            -
              #   Open3.pipeline_rw(cmd1, cmd2, ... [, opts]) {|first_stdin, last_stdout, wait_threads|
         | 
| 853 | 
            -
              #     ...
         | 
| 854 | 
            -
              #   }
         | 
| 934 | 
            +
              # :call-seq:
         | 
| 935 | 
            +
              #   Open3.pipeline_rw([env, ] *cmds, options = {}) -> [first_stdin, last_stdout, wait_threads]
         | 
| 855 936 | 
             
              #
         | 
| 856 | 
            -
              # | 
| 857 | 
            -
              # | 
| 858 | 
            -
              # | 
| 859 | 
            -
              #   last_stdout.close
         | 
| 937 | 
            +
              # Basically a wrapper for
         | 
| 938 | 
            +
              # {Process.spawn}[https://docs.ruby-lang.org/en/master/Process.html#method-c-spawn]
         | 
| 939 | 
            +
              # that:
         | 
| 860 940 | 
             
              #
         | 
| 861 | 
            -
              #  | 
| 862 | 
            -
              #  | 
| 941 | 
            +
              # - Creates a child process for each of the given +cmds+
         | 
| 942 | 
            +
              #   by calling Process.spawn.
         | 
| 943 | 
            +
              # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
         | 
| 944 | 
            +
              #   or, for the first child, from the caller's +stdin+,
         | 
| 945 | 
            +
              #   or, for the last child, to the caller's +stdout+.
         | 
| 863 946 | 
             
              #
         | 
| 864 | 
            -
              # | 
| 865 | 
            -
              # | 
| 866 | 
            -
              #     [env, commandline, opts]                 command line string which is passed to a shell
         | 
| 867 | 
            -
              #     [env, cmdname, arg1, ..., opts]          command name and one or more arguments (no shell)
         | 
| 868 | 
            -
              #     [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
         | 
| 947 | 
            +
              # The method does not wait for child processes to exit,
         | 
| 948 | 
            +
              # so the caller must do so.
         | 
| 869 949 | 
             
              #
         | 
| 870 | 
            -
              # | 
| 950 | 
            +
              # With no block given, returns a 3-element array containing:
         | 
| 871 951 | 
             
              #
         | 
| 872 | 
            -
              # The  | 
| 873 | 
            -
              #  | 
| 874 | 
            -
              #  | 
| 952 | 
            +
              # - The +stdin+ stream of the first child process.
         | 
| 953 | 
            +
              # - The +stdout+ stream of the last child process.
         | 
| 954 | 
            +
              # - An array of the wait threads for all of the child processes.
         | 
| 875 955 | 
             
              #
         | 
| 876 956 | 
             
              # Example:
         | 
| 877 957 | 
             
              #
         | 
| 878 | 
            -
              #   Open3.pipeline_rw( | 
| 879 | 
            -
              # | 
| 880 | 
            -
              # | 
| 881 | 
            -
              # | 
| 882 | 
            -
              #    | 
| 883 | 
            -
              #
         | 
| 884 | 
            -
              # | 
| 885 | 
            -
              # | 
| 886 | 
            -
              # | 
| 887 | 
            -
              # | 
| 888 | 
            -
              # | 
| 889 | 
            -
              # | 
| 890 | 
            -
              #    | 
| 958 | 
            +
              #   first_stdin, last_stdout, wait_threads = Open3.pipeline_rw('sort', 'cat -n')
         | 
| 959 | 
            +
              #   # => [#<IO:fd 20>, #<IO:fd 21>, [#<Process::Waiter:0x000055e8de29ab40 sleep>, #<Process::Waiter:0x000055e8de29a690 sleep>]]
         | 
| 960 | 
            +
              #   first_stdin.puts("foo\nbar\nbaz")
         | 
| 961 | 
            +
              #   first_stdin.close # Send EOF to sort.
         | 
| 962 | 
            +
              #   puts last_stdout.read
         | 
| 963 | 
            +
              #   wait_threads.each do |wait_thread|
         | 
| 964 | 
            +
              #     wait_thread.join
         | 
| 965 | 
            +
              #   end
         | 
| 966 | 
            +
              #
         | 
| 967 | 
            +
              # Output:
         | 
| 968 | 
            +
              #
         | 
| 969 | 
            +
              #   1	bar
         | 
| 970 | 
            +
              #   2	baz
         | 
| 971 | 
            +
              #   3	foo
         | 
| 972 | 
            +
              #
         | 
| 973 | 
            +
              # With a block given, calls the block with the +stdin+ stream of the first child,
         | 
| 974 | 
            +
              # the +stdout+ stream  of the last child,
         | 
| 975 | 
            +
              # and an array of the wait processes:
         | 
| 976 | 
            +
              #
         | 
| 977 | 
            +
              #   Open3.pipeline_rw('sort', 'cat -n') do |first_stdin, last_stdout, wait_threads|
         | 
| 978 | 
            +
              #     first_stdin.puts "foo\nbar\nbaz"
         | 
| 979 | 
            +
              #     first_stdin.close # send EOF to sort.
         | 
| 980 | 
            +
              #     puts last_stdout.read
         | 
| 981 | 
            +
              #     wait_threads.each do |wait_thread|
         | 
| 982 | 
            +
              #       wait_thread.join
         | 
| 983 | 
            +
              #     end
         | 
| 984 | 
            +
              #   end
         | 
| 985 | 
            +
              #
         | 
| 986 | 
            +
              # Output:
         | 
| 987 | 
            +
              #
         | 
| 988 | 
            +
              #   1	bar
         | 
| 989 | 
            +
              #   2	baz
         | 
| 990 | 
            +
              #   3	foo
         | 
| 991 | 
            +
              #
         | 
| 992 | 
            +
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 993 | 
            +
              # if called with untrusted input;
         | 
| 994 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 995 | 
            +
              #
         | 
| 996 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 997 | 
            +
              # in each call to Process.spawn;
         | 
| 998 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 999 | 
            +
              #
         | 
| 1000 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 1001 | 
            +
              # in each call to Process.spawn;
         | 
| 1002 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 1003 | 
            +
              #
         | 
| 1004 | 
            +
              # Each remaining argument in +cmds+ is one of:
         | 
| 1005 | 
            +
              #
         | 
| 1006 | 
            +
              # - A +command_line+: a string that begins with a shell reserved word
         | 
| 1007 | 
            +
              #   or special built-in, or contains one or more metacharacters.
         | 
| 1008 | 
            +
              # - An +exe_path+: the string path to an executable to be called.
         | 
| 1009 | 
            +
              # - An array containing a +command_line+ or an +exe_path+,
         | 
| 1010 | 
            +
              #   along with zero or more string arguments for the command.
         | 
| 1011 | 
            +
              #
         | 
| 1012 | 
            +
              # See {Argument command_line or exe_path}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Argument+command_line+or+exe_path].
         | 
| 1013 | 
            +
              #
         | 
| 891 1014 | 
             
              def pipeline_rw(*cmds, &block)
         | 
| 892 1015 | 
             
                if Hash === cmds.last
         | 
| 893 1016 | 
             
                  opts = cmds.pop.dup
         | 
| @@ -906,43 +1029,77 @@ module Open3 | |
| 906 1029 | 
             
              end
         | 
| 907 1030 | 
             
              module_function :pipeline_rw
         | 
| 908 1031 |  | 
| 909 | 
            -
              #  | 
| 910 | 
            -
              #  | 
| 1032 | 
            +
              # :call-seq:
         | 
| 1033 | 
            +
              #   Open3.pipeline_r([env, ] *cmds, options = {}) -> [last_stdout, wait_threads]
         | 
| 911 1034 | 
             
              #
         | 
| 912 | 
            -
              # | 
| 913 | 
            -
              # | 
| 914 | 
            -
              # | 
| 1035 | 
            +
              # Basically a wrapper for
         | 
| 1036 | 
            +
              # {Process.spawn}[https://docs.ruby-lang.org/en/master/Process.html#method-c-spawn]
         | 
| 1037 | 
            +
              # that:
         | 
| 915 1038 | 
             
              #
         | 
| 916 | 
            -
              # | 
| 917 | 
            -
              #    | 
| 918 | 
            -
              # | 
| 1039 | 
            +
              # - Creates a child process for each of the given +cmds+
         | 
| 1040 | 
            +
              #   by calling Process.spawn.
         | 
| 1041 | 
            +
              # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
         | 
| 1042 | 
            +
              #   or, for the last child, to the caller's +stdout+.
         | 
| 919 1043 | 
             
              #
         | 
| 920 | 
            -
              #  | 
| 921 | 
            -
              #  | 
| 1044 | 
            +
              # The method does not wait for child processes to exit,
         | 
| 1045 | 
            +
              # so the caller must do so.
         | 
| 922 1046 | 
             
              #
         | 
| 923 | 
            -
              # | 
| 924 | 
            -
              #     commandline                              command line string which is passed to a shell
         | 
| 925 | 
            -
              #     [env, commandline, opts]                 command line string which is passed to a shell
         | 
| 926 | 
            -
              #     [env, cmdname, arg1, ..., opts]          command name and one or more arguments (no shell)
         | 
| 927 | 
            -
              #     [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
         | 
| 1047 | 
            +
              # With no block given, returns a 2-element array containing:
         | 
| 928 1048 | 
             
              #
         | 
| 929 | 
            -
              # | 
| 1049 | 
            +
              # - The +stdout+ stream of the last child process.
         | 
| 1050 | 
            +
              # - An array of the wait threads for all of the child processes.
         | 
| 930 1051 | 
             
              #
         | 
| 931 1052 | 
             
              # Example:
         | 
| 932 1053 | 
             
              #
         | 
| 933 | 
            -
              #   Open3.pipeline_r( | 
| 934 | 
            -
              # | 
| 935 | 
            -
              # | 
| 936 | 
            -
              # | 
| 937 | 
            -
              # | 
| 938 | 
            -
              # | 
| 939 | 
            -
              # | 
| 1054 | 
            +
              #   last_stdout, wait_threads = Open3.pipeline_r('ls', 'grep R')
         | 
| 1055 | 
            +
              #   # => [#<IO:fd 5>, [#<Process::Waiter:0x000055e8de2f9898 dead>, #<Process::Waiter:0x000055e8de2f94b0 sleep>]]
         | 
| 1056 | 
            +
              #   puts last_stdout.read
         | 
| 1057 | 
            +
              #   wait_threads.each do |wait_thread|
         | 
| 1058 | 
            +
              #     wait_thread.join
         | 
| 1059 | 
            +
              #   end
         | 
| 1060 | 
            +
              #
         | 
| 1061 | 
            +
              # Output:
         | 
| 1062 | 
            +
              #
         | 
| 1063 | 
            +
              #   Rakefile
         | 
| 1064 | 
            +
              #   README.md
         | 
| 1065 | 
            +
              #
         | 
| 1066 | 
            +
              # With a block given, calls the block with the +stdout+ stream
         | 
| 1067 | 
            +
              # of the last child process,
         | 
| 1068 | 
            +
              # and an array of the wait processes:
         | 
| 1069 | 
            +
              #
         | 
| 1070 | 
            +
              #   Open3.pipeline_r('ls', 'grep R') do |last_stdout, wait_threads|
         | 
| 1071 | 
            +
              #     puts last_stdout.read
         | 
| 1072 | 
            +
              #     wait_threads.each do |wait_thread|
         | 
| 1073 | 
            +
              #       wait_thread.join
         | 
| 1074 | 
            +
              #     end
         | 
| 1075 | 
            +
              #   end
         | 
| 1076 | 
            +
              #
         | 
| 1077 | 
            +
              # Output:
         | 
| 1078 | 
            +
              #
         | 
| 1079 | 
            +
              #   Rakefile
         | 
| 1080 | 
            +
              #   README.md
         | 
| 1081 | 
            +
              #
         | 
| 1082 | 
            +
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 1083 | 
            +
              # if called with untrusted input;
         | 
| 1084 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 1085 | 
            +
              #
         | 
| 1086 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 1087 | 
            +
              # in each call to Process.spawn;
         | 
| 1088 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 1089 | 
            +
              #
         | 
| 1090 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 1091 | 
            +
              # in each call to Process.spawn;
         | 
| 1092 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 1093 | 
            +
              #
         | 
| 1094 | 
            +
              # Each remaining argument in +cmds+ is one of:
         | 
| 940 1095 | 
             
              #
         | 
| 941 | 
            -
              # | 
| 942 | 
            -
              # | 
| 943 | 
            -
              # | 
| 944 | 
            -
              # | 
| 945 | 
            -
              #    | 
| 1096 | 
            +
              # - A +command_line+: a string that begins with a shell reserved word
         | 
| 1097 | 
            +
              #   or special built-in, or contains one or more metacharacters.
         | 
| 1098 | 
            +
              # - An +exe_path+: the string path to an executable to be called.
         | 
| 1099 | 
            +
              # - An array containing a +command_line+ or an +exe_path+,
         | 
| 1100 | 
            +
              #   along with zero or more string arguments for the command.
         | 
| 1101 | 
            +
              #
         | 
| 1102 | 
            +
              # See {Argument command_line or exe_path}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Argument+command_line+or+exe_path].
         | 
| 946 1103 | 
             
              #
         | 
| 947 1104 | 
             
              def pipeline_r(*cmds, &block)
         | 
| 948 1105 | 
             
                if Hash === cmds.last
         | 
| @@ -958,33 +1115,82 @@ module Open3 | |
| 958 1115 | 
             
              end
         | 
| 959 1116 | 
             
              module_function :pipeline_r
         | 
| 960 1117 |  | 
| 961 | 
            -
             | 
| 962 | 
            -
              #  | 
| 1118 | 
            +
             | 
| 1119 | 
            +
              # :call-seq:
         | 
| 1120 | 
            +
              #   Open3.pipeline_w([env, ] *cmds, options = {}) -> [first_stdin, wait_threads]
         | 
| 963 1121 | 
             
              #
         | 
| 964 | 
            -
              # | 
| 965 | 
            -
              # | 
| 966 | 
            -
              # | 
| 1122 | 
            +
              # Basically a wrapper for
         | 
| 1123 | 
            +
              # {Process.spawn}[https://docs.ruby-lang.org/en/master/Process.html#method-c-spawn]
         | 
| 1124 | 
            +
              # that:
         | 
| 967 1125 | 
             
              #
         | 
| 968 | 
            -
              # | 
| 969 | 
            -
              #    | 
| 970 | 
            -
              # | 
| 1126 | 
            +
              # - Creates a child process for each of the given +cmds+
         | 
| 1127 | 
            +
              #   by calling Process.spawn.
         | 
| 1128 | 
            +
              # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
         | 
| 1129 | 
            +
              #   or, for the first child, pipes the caller's +stdout+ to the child's +stdin+.
         | 
| 971 1130 | 
             
              #
         | 
| 972 | 
            -
              #  | 
| 973 | 
            -
              #  | 
| 1131 | 
            +
              # The method does not wait for child processes to exit,
         | 
| 1132 | 
            +
              # so the caller must do so.
         | 
| 974 1133 | 
             
              #
         | 
| 975 | 
            -
              # | 
| 976 | 
            -
              #     commandline                              command line string which is passed to a shell
         | 
| 977 | 
            -
              #     [env, commandline, opts]                 command line string which is passed to a shell
         | 
| 978 | 
            -
              #     [env, cmdname, arg1, ..., opts]          command name and one or more arguments (no shell)
         | 
| 979 | 
            -
              #     [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
         | 
| 1134 | 
            +
              # With no block given, returns a 2-element array containing:
         | 
| 980 1135 | 
             
              #
         | 
| 981 | 
            -
              # | 
| 1136 | 
            +
              # - The +stdin+ stream of the first child process.
         | 
| 1137 | 
            +
              # - An array of the wait threads for all of the child processes.
         | 
| 982 1138 | 
             
              #
         | 
| 983 1139 | 
             
              # Example:
         | 
| 984 1140 | 
             
              #
         | 
| 985 | 
            -
              #   Open3.pipeline_w( | 
| 986 | 
            -
              # | 
| 987 | 
            -
              #    | 
| 1141 | 
            +
              #   first_stdin, wait_threads = Open3.pipeline_w('sort', 'cat -n')
         | 
| 1142 | 
            +
              #   # => [#<IO:fd 7>, [#<Process::Waiter:0x000055e8de928278 run>, #<Process::Waiter:0x000055e8de923e80 run>]]
         | 
| 1143 | 
            +
              #   first_stdin.puts("foo\nbar\nbaz")
         | 
| 1144 | 
            +
              #   first_stdin.close # Send EOF to sort.
         | 
| 1145 | 
            +
              #   wait_threads.each do |wait_thread|
         | 
| 1146 | 
            +
              #     wait_thread.join
         | 
| 1147 | 
            +
              #   end
         | 
| 1148 | 
            +
              #
         | 
| 1149 | 
            +
              # Output:
         | 
| 1150 | 
            +
              #
         | 
| 1151 | 
            +
              #   1	bar
         | 
| 1152 | 
            +
              #   2	baz
         | 
| 1153 | 
            +
              #   3	foo
         | 
| 1154 | 
            +
              #
         | 
| 1155 | 
            +
              # With a block given, calls the block with the +stdin+ stream
         | 
| 1156 | 
            +
              # of the first child process,
         | 
| 1157 | 
            +
              # and an array of the wait processes:
         | 
| 1158 | 
            +
              #
         | 
| 1159 | 
            +
              #   Open3.pipeline_w('sort', 'cat -n') do |first_stdin, wait_threads|
         | 
| 1160 | 
            +
              #     first_stdin.puts("foo\nbar\nbaz")
         | 
| 1161 | 
            +
              #     first_stdin.close # Send EOF to sort.
         | 
| 1162 | 
            +
              #     wait_threads.each do |wait_thread|
         | 
| 1163 | 
            +
              #       wait_thread.join
         | 
| 1164 | 
            +
              #     end
         | 
| 1165 | 
            +
              #   end
         | 
| 1166 | 
            +
              #
         | 
| 1167 | 
            +
              # Output:
         | 
| 1168 | 
            +
              #
         | 
| 1169 | 
            +
              #   1	bar
         | 
| 1170 | 
            +
              #   2	baz
         | 
| 1171 | 
            +
              #   3	foo
         | 
| 1172 | 
            +
              #
         | 
| 1173 | 
            +
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 1174 | 
            +
              # if called with untrusted input;
         | 
| 1175 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 1176 | 
            +
              #
         | 
| 1177 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 1178 | 
            +
              # in each call to Process.spawn;
         | 
| 1179 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 1180 | 
            +
              #
         | 
| 1181 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 1182 | 
            +
              # in each call to Process.spawn;
         | 
| 1183 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 1184 | 
            +
              #
         | 
| 1185 | 
            +
              # Each remaining argument in +cmds+ is one of:
         | 
| 1186 | 
            +
              #
         | 
| 1187 | 
            +
              # - A +command_line+: a string that begins with a shell reserved word
         | 
| 1188 | 
            +
              #   or special built-in, or contains one or more metacharacters.
         | 
| 1189 | 
            +
              # - An +exe_path+: the string path to an executable to be called.
         | 
| 1190 | 
            +
              # - An array containing a +command_line+ or an +exe_path+,
         | 
| 1191 | 
            +
              #   along with zero or more string arguments for the command.
         | 
| 1192 | 
            +
              #
         | 
| 1193 | 
            +
              # See {Argument command_line or exe_path}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Argument+command_line+or+exe_path].
         | 
| 988 1194 | 
             
              #
         | 
| 989 1195 | 
             
              def pipeline_w(*cmds, &block)
         | 
| 990 1196 | 
             
                if Hash === cmds.last
         | 
| @@ -1001,49 +1207,67 @@ module Open3 | |
| 1001 1207 | 
             
              end
         | 
| 1002 1208 | 
             
              module_function :pipeline_w
         | 
| 1003 1209 |  | 
| 1004 | 
            -
              #  | 
| 1005 | 
            -
              #  | 
| 1006 | 
            -
              # stdout of the last command.
         | 
| 1210 | 
            +
              # :call-seq:
         | 
| 1211 | 
            +
              #   Open3.pipeline_start([env, ] *cmds, options = {}) -> [wait_threads]
         | 
| 1007 1212 | 
             
              #
         | 
| 1008 | 
            -
              # | 
| 1009 | 
            -
              # | 
| 1010 | 
            -
              # | 
| 1213 | 
            +
              # Basically a wrapper for
         | 
| 1214 | 
            +
              # {Process.spawn}[https://docs.ruby-lang.org/en/master/Process.html#method-c-spawn]
         | 
| 1215 | 
            +
              # that:
         | 
| 1011 1216 | 
             
              #
         | 
| 1012 | 
            -
              # | 
| 1013 | 
            -
              #    | 
| 1217 | 
            +
              # - Creates a child process for each of the given +cmds+
         | 
| 1218 | 
            +
              #   by calling Process.spawn.
         | 
| 1219 | 
            +
              # - Does not wait for child processes to exit.
         | 
| 1014 1220 | 
             
              #
         | 
| 1015 | 
            -
              #  | 
| 1016 | 
            -
              #  | 
| 1221 | 
            +
              # With no block given, returns an array of the wait threads
         | 
| 1222 | 
            +
              # for all of the child processes.
         | 
| 1017 1223 | 
             
              #
         | 
| 1018 | 
            -
              # | 
| 1019 | 
            -
              #     commandline                              command line string which is passed to a shell
         | 
| 1020 | 
            -
              #     [env, commandline, opts]                 command line string which is passed to a shell
         | 
| 1021 | 
            -
              #     [env, cmdname, arg1, ..., opts]          command name and one or more arguments (no shell)
         | 
| 1022 | 
            -
              #     [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
         | 
| 1224 | 
            +
              # Example:
         | 
| 1023 1225 | 
             
              #
         | 
| 1024 | 
            -
              #    | 
| 1226 | 
            +
              #   wait_threads = Open3.pipeline_start('ls', 'grep R')
         | 
| 1227 | 
            +
              #   # => [#<Process::Waiter:0x000055e8de9d2bb0 run>, #<Process::Waiter:0x000055e8de9d2890 run>]
         | 
| 1228 | 
            +
              #   wait_threads.each do |wait_thread|
         | 
| 1229 | 
            +
              #     wait_thread.join
         | 
| 1230 | 
            +
              #   end
         | 
| 1025 1231 | 
             
              #
         | 
| 1026 | 
            -
              #  | 
| 1232 | 
            +
              # Output:
         | 
| 1027 1233 | 
             
              #
         | 
| 1028 | 
            -
              #    | 
| 1029 | 
            -
              #    | 
| 1030 | 
            -
              # | 
| 1031 | 
            -
              # | 
| 1032 | 
            -
              # | 
| 1033 | 
            -
              # | 
| 1034 | 
            -
              # | 
| 1035 | 
            -
              #
         | 
| 1036 | 
            -
              # | 
| 1037 | 
            -
              #    | 
| 1038 | 
            -
              # | 
| 1039 | 
            -
              # | 
| 1040 | 
            -
              # | 
| 1041 | 
            -
              #    | 
| 1042 | 
            -
              # | 
| 1043 | 
            -
              # | 
| 1044 | 
            -
              # | 
| 1045 | 
            -
              # | 
| 1046 | 
            -
              # | 
| 1234 | 
            +
              #   Rakefile
         | 
| 1235 | 
            +
              #   README.md
         | 
| 1236 | 
            +
              #
         | 
| 1237 | 
            +
              # With a block given, calls the block with an array of the wait processes:
         | 
| 1238 | 
            +
              #
         | 
| 1239 | 
            +
              #   Open3.pipeline_start('ls', 'grep R') do |wait_threads|
         | 
| 1240 | 
            +
              #     wait_threads.each do |wait_thread|
         | 
| 1241 | 
            +
              #       wait_thread.join
         | 
| 1242 | 
            +
              #     end
         | 
| 1243 | 
            +
              #   end
         | 
| 1244 | 
            +
              #
         | 
| 1245 | 
            +
              # Output:
         | 
| 1246 | 
            +
              #
         | 
| 1247 | 
            +
              #   Rakefile
         | 
| 1248 | 
            +
              #   README.md
         | 
| 1249 | 
            +
              #
         | 
| 1250 | 
            +
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 1251 | 
            +
              # if called with untrusted input;
         | 
| 1252 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 1253 | 
            +
              #
         | 
| 1254 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 1255 | 
            +
              # in each call to Process.spawn;
         | 
| 1256 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 1257 | 
            +
              #
         | 
| 1258 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 1259 | 
            +
              # in each call to Process.spawn;
         | 
| 1260 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 1261 | 
            +
              #
         | 
| 1262 | 
            +
              # Each remaining argument in +cmds+ is one of:
         | 
| 1263 | 
            +
              #
         | 
| 1264 | 
            +
              # - A +command_line+: a string that begins with a shell reserved word
         | 
| 1265 | 
            +
              #   or special built-in, or contains one or more metacharacters.
         | 
| 1266 | 
            +
              # - An +exe_path+: the string path to an executable to be called.
         | 
| 1267 | 
            +
              # - An array containing a +command_line+ or an +exe_path+,
         | 
| 1268 | 
            +
              #   along with zero or more string arguments for the command.
         | 
| 1269 | 
            +
              #
         | 
| 1270 | 
            +
              # See {Argument command_line or exe_path}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Argument+command_line+or+exe_path].
         | 
| 1047 1271 | 
             
              #
         | 
| 1048 1272 | 
             
              def pipeline_start(*cmds, &block)
         | 
| 1049 1273 | 
             
                if Hash === cmds.last
         | 
| @@ -1061,57 +1285,51 @@ module Open3 | |
| 1061 1285 | 
             
              end
         | 
| 1062 1286 | 
             
              module_function :pipeline_start
         | 
| 1063 1287 |  | 
| 1064 | 
            -
              #  | 
| 1065 | 
            -
              #  | 
| 1066 | 
            -
              # No pipes are created for stdin of the first command and
         | 
| 1067 | 
            -
              # stdout of the last command.
         | 
| 1288 | 
            +
              # :call-seq:
         | 
| 1289 | 
            +
              #   Open3.pipeline([env, ] *cmds, options = {}) -> array_of_statuses
         | 
| 1068 1290 | 
             
              #
         | 
| 1069 | 
            -
              # | 
| 1291 | 
            +
              # Basically a wrapper for
         | 
| 1292 | 
            +
              # {Process.spawn}[https://docs.ruby-lang.org/en/master/Process.html#method-c-spawn]
         | 
| 1293 | 
            +
              # that:
         | 
| 1070 1294 | 
             
              #
         | 
| 1071 | 
            -
              #  | 
| 1072 | 
            -
              #  | 
| 1295 | 
            +
              # - Creates a child process for each of the given +cmds+
         | 
| 1296 | 
            +
              #   by calling Process.spawn.
         | 
| 1297 | 
            +
              # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
         | 
| 1298 | 
            +
              #   or, for the last child, to the caller's +stdout+.
         | 
| 1299 | 
            +
              # - Waits for the child processes to exit.
         | 
| 1300 | 
            +
              # - Returns an array of Process::Status objects (one for each child).
         | 
| 1073 1301 | 
             
              #
         | 
| 1074 | 
            -
              # | 
| 1075 | 
            -
              #     commandline                              command line string which is passed to a shell
         | 
| 1076 | 
            -
              #     [env, commandline, opts]                 command line string which is passed to a shell
         | 
| 1077 | 
            -
              #     [env, cmdname, arg1, ..., opts]          command name and one or more arguments (no shell)
         | 
| 1078 | 
            -
              #     [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
         | 
| 1302 | 
            +
              # Example:
         | 
| 1079 1303 | 
             
              #
         | 
| 1080 | 
            -
              #    | 
| 1304 | 
            +
              #   wait_threads = Open3.pipeline('ls', 'grep R')
         | 
| 1305 | 
            +
              #   # => [#<Process::Status: pid 2139200 exit 0>, #<Process::Status: pid 2139202 exit 0>]
         | 
| 1081 1306 | 
             
              #
         | 
| 1082 | 
            -
              #  | 
| 1307 | 
            +
              # Output:
         | 
| 1308 | 
            +
              #
         | 
| 1309 | 
            +
              #   Rakefile
         | 
| 1310 | 
            +
              #   README.md
         | 
| 1311 | 
            +
              #
         | 
| 1312 | 
            +
              # Like Process.spawn, this method has potential security vulnerabilities
         | 
| 1313 | 
            +
              # if called with untrusted input;
         | 
| 1314 | 
            +
              # see {Command Injection}[https://docs.ruby-lang.org/en/master/command_injection_rdoc.html#label-Command+Injection].
         | 
| 1315 | 
            +
              #
         | 
| 1316 | 
            +
              # If the first argument is a hash, it becomes leading argument +env+
         | 
| 1317 | 
            +
              # in each call to Process.spawn;
         | 
| 1318 | 
            +
              # see {Execution Environment}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Environment].
         | 
| 1319 | 
            +
              #
         | 
| 1320 | 
            +
              # If the last argument is a hash, it becomes trailing argument +options+
         | 
| 1321 | 
            +
              # in each call to Process.spawn'
         | 
| 1322 | 
            +
              # see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
         | 
| 1323 | 
            +
              #
         | 
| 1324 | 
            +
              # Each remaining argument in +cmds+ is one of:
         | 
| 1325 | 
            +
              #
         | 
| 1326 | 
            +
              # - A +command_line+: a string that begins with a shell reserved word
         | 
| 1327 | 
            +
              #   or special built-in, or contains one or more metacharacters.
         | 
| 1328 | 
            +
              # - An +exe_path+: the string path to an executable to be called.
         | 
| 1329 | 
            +
              # - An array containing a +command_line+ or an +exe_path+,
         | 
| 1330 | 
            +
              #   along with zero or more string arguments for the command.
         | 
| 1083 1331 | 
             
              #
         | 
| 1084 | 
            -
              # | 
| 1085 | 
            -
              #   p Open3.pipeline(["zcat", fname], "nroff -man", "less")
         | 
| 1086 | 
            -
              #   #=> [#<Process::Status: pid 11817 exit 0>,
         | 
| 1087 | 
            -
              #   #    #<Process::Status: pid 11820 exit 0>,
         | 
| 1088 | 
            -
              #   #    #<Process::Status: pid 11828 exit 0>]
         | 
| 1089 | 
            -
              #
         | 
| 1090 | 
            -
              #   fname = "/usr/share/man/man1/ls.1.gz"
         | 
| 1091 | 
            -
              #   Open3.pipeline(["zcat", fname], "nroff -man", "colcrt")
         | 
| 1092 | 
            -
              #
         | 
| 1093 | 
            -
              #   # convert PDF to PS and send to a printer by lpr
         | 
| 1094 | 
            -
              #   pdf_file = "paper.pdf"
         | 
| 1095 | 
            -
              #   printer = "printer-name"
         | 
| 1096 | 
            -
              #   Open3.pipeline(["pdftops", pdf_file, "-"],
         | 
| 1097 | 
            -
              #                  ["lpr", "-P#{printer}"])
         | 
| 1098 | 
            -
              #
         | 
| 1099 | 
            -
              #   # count lines
         | 
| 1100 | 
            -
              #   Open3.pipeline("sort", "uniq -c", :in=>"names.txt", :out=>"count")
         | 
| 1101 | 
            -
              #
         | 
| 1102 | 
            -
              #   # cyclic pipeline
         | 
| 1103 | 
            -
              #   r,w = IO.pipe
         | 
| 1104 | 
            -
              #   w.print "ibase=14\n10\n"
         | 
| 1105 | 
            -
              #   Open3.pipeline("bc", "tee /dev/tty", :in=>r, :out=>w)
         | 
| 1106 | 
            -
              #   #=> 14
         | 
| 1107 | 
            -
              #   #   18
         | 
| 1108 | 
            -
              #   #   22
         | 
| 1109 | 
            -
              #   #   30
         | 
| 1110 | 
            -
              #   #   42
         | 
| 1111 | 
            -
              #   #   58
         | 
| 1112 | 
            -
              #   #   78
         | 
| 1113 | 
            -
              #   #   106
         | 
| 1114 | 
            -
              #   #   202
         | 
| 1332 | 
            +
              # See {Argument command_line or exe_path}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Argument+command_line+or+exe_path].
         | 
| 1115 1333 | 
             
              #
         | 
| 1116 1334 | 
             
              def pipeline(*cmds)
         | 
| 1117 1335 | 
             
                if Hash === cmds.last
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: open3
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Yukihiro Matsumoto
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023- | 
| 11 | 
            +
            date: 2023-12-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: Popen, but with stderr, too
         | 
| 14 14 | 
             
            email:
         |