Last active
          August 29, 2015 13:57 
        
      - 
      
- 
        Save rurban/9605572 to your computer and use it in GitHub Desktop. 
    rakudo: parrot openpipe with rurban/openpipe-env-gh1065
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | sub QX($cmd) { | |
| #if? parrot | |
| my $pipe := pir::new__Ps('FileHandle'); | |
| my $env := pir::new__Ps('Env'); | |
| $pipe.set_keyed('env', $env); | |
| $pipe.open(nqp::unbox_s($cmd), 'rp'); | |
| fail "Unable to execute '$cmd'" unless $pipe; | |
| $pipe.encoding('utf8'); | |
| my $result := $pipe.readall; | |
| $pipe.close(); | |
| store_dynlex_safely('$!', $pipe.exit_status); | |
| $result | |
| #?endif | |
| #?if !parrot | |
| my Mu $pio := nqp::openpipe(nqp::unbox_s($cmd), nqp::cwd(), nqp::getenvhash(), ''); | |
| fail "Unable to execute '$cmd'" unless $pio; | |
| my $result = nqp::p6box_s(nqp::readallfh($pio)); | |
| nqp::closefh($pio); | |
| $result; | |
| #?endif | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment