commit | 2a896e26c7dee68a78d7e8639a566403df585b2c | [log] [tgz] |
---|---|---|
author | Keith Rarick <kr@xph.us> | Mon Dec 03 23:12:11 2012 -0800 |
committer | Keith Rarick <kr@xph.us> | Mon Dec 03 23:12:11 2012 -0800 |
tree | 3076daeb0745c4496b3b64858edf1ce25e299211 | |
parent | 02033fc6c5596e27757e4d8ecb2932d3fae7dd2e [diff] |
darwin support Based on ac3ece1daaeceefc932554c918ac98c4d4bdbe24 by Burke Libbey <burke@libbey.me>.
Pty is a Go package for using unix pseudo-terminals.
(Note, there is only a Linux implementation. I'd appreciate a patch for other systems!)
go get github.com/kr/pty
package main
import (
"fmt"
"github.com/kr/pty"
"io"
"os"
"os/exec"
)
func main() {
c := exec.Command("grep", "--color=auto", "bar")
f, err := pty.Start(c)
if err != nil {
panic(err)
}
go func() {
fmt.Fprintln(f, "foo")
fmt.Fprintln(f, "bar")
fmt.Fprintln(f, "baz")
f.Close()
}()
io.Copy(os.Stdout, f)
c.Wait()
}