This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| my class IO::Pipe does IO { | |
| method open($command, *%opts) { | |
| my Mu $env := nqp::getattr(%*ENV, EnumMap, '$!storage'); | |
| my Mu $pio := nqp::openpipe(nqp::unbox_s($command), $*CWD.Str, $env, ''); | |
| fail "Unable to execute '$command'" unless $pio; | |
| my $pipe := IO::Handle.new(); | |
| nqp::bindattr($pipe, IO::Handle, '$!PIO', $pio); | |
| $pipe; | |
| } | |
| method from($command, *%opts) { | |
| self.open($command, |%opts); | |
| } | |
| method to($command, *%opts) { | |
| self.open($command, |%opts); | |
| } | |
| } | |
| my $pipe = IO::Pipe.from('cat CREDITS'); | |
| say $pipe.lines.join("\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment