commit | 9e03abc5be1268ac16a690a5b054277751aaced8 | [log] [tgz] |
---|---|---|
author | Sherjil Ozair <sherjilozair@gmail.com> | Wed Jun 13 13:29:54 2012 +0100 |
committer | Sherjil Ozair <sherjilozair@gmail.com> | Wed Jun 13 13:29:54 2012 +0100 |
tree | 5494d2bb462aea177fa624f26a3f6f80a7b1f099 | |
parent | 44e8fe6bc91a1145a342e6c37e1926e66b3ead3b [diff] |
Some changes to make the code compile with GO version 1.0.1. However, there would be also be some changes in functionality. This is due to changes in the type of cmd.Stdin and cmd.Stdout, and their inability to write as well read. The example given in readme.md doesn't work. I'm figuring out a way to make changes in the example so that it works.
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!)
goinstall github.com/kr/pty
package main import ( "fmt" "github.com/kr/pty" "io" "os" ) func main() { c, err := pty.Run( "/bin/grep", []string{"grep", "--color=auto", "bar"}, nil, "", ) if err != nil { panic(err) } go func() { fmt.Fprintln(c.Stdin, "foo") fmt.Fprintln(c.Stdin, "bar") fmt.Fprintln(c.Stdin, "baz") c.Stdin.Close() }() io.Copy(os.Stdout, c.Stdout) c.Wait(0) }