Created
June 23, 2017 08:14
-
-
Save matti/7e44cd9ebfb75bc5e0a89ef33a09b594 to your computer and use it in GitHub Desktop.
Separates Ruby PTY spawn stderr from stdout
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
require "pty" | |
stderr_reader, stderr_writer = IO.pipe | |
args = ["-c", "read a; echo was: $a; echo err:$a >&2"] | |
stdout,stdin,pid = PTY.spawn("/bin/bash", *args, err: stderr_writer.fileno) | |
stderr_writer.close | |
stdin.puts "hello" | |
puts stdout.read | |
puts stderr_reader.read |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx for
stderr
! https://gist.github.com/pre/67c04d0a64abc1929c9ef9ffd3c4469c