File tree Expand file tree Collapse file tree 5 files changed +52
-27
lines changed Expand file tree Collapse file tree 5 files changed +52
-27
lines changed Original file line number Diff line number Diff line change 17
17
[[constraint ]]
18
18
branch = " master"
19
19
name = " github.com/amoghe/distillog"
20
-
21
- [[constraint ]]
22
- name = " github.com/kr/pty"
23
- version = " 1.1.4"
Original file line number Diff line number Diff line change 1
1
package inout
2
2
3
3
import (
4
- "os "
4
+ "io "
5
5
"os/exec"
6
6
"errors"
7
7
"strings"
8
-
9
- "github.com/kr/pty"
10
8
)
11
9
12
- func NewExecArgs (args []string ) (* os.File , error ) {
10
+ type RWC struct {
11
+ io.Reader
12
+ io.Writer
13
+ io.Closer
14
+ }
15
+
16
+ func NewReadWriteCloser (r io.Reader , w io.Writer , c io.Closer ) io.ReadWriteCloser {
17
+ return RWC {r , w , c }
18
+ }
19
+
20
+ func NewExecArgs (args []string ) (* RWC , error ) {
13
21
var c * exec.Cmd
14
22
15
23
if len (args ) > 1 {
@@ -20,9 +28,14 @@ func NewExecArgs(args []string) (*os.File, error) {
20
28
return nil , errors .New ("No command given" )
21
29
}
22
30
23
- return pty .Start (c )
31
+ // TODO: Run it in a TTY
32
+ // TODO: Combine Stderr
33
+ si , _ := c .StdinPipe ()
34
+ so , _ := c .StdoutPipe ()
35
+
36
+ return & RWC {so , si , nil }, c .Start ()
24
37
}
25
38
26
- func NewExec (cmd string ) (* os. File , error ) {
39
+ func NewExec (cmd string ) (* RWC , error ) {
27
40
return NewExecArgs (strings .Split (cmd , " " ))
28
41
}
Original file line number Diff line number Diff line change 1
1
package inout
2
2
3
3
import (
4
- "golang.org/x/sys/unix"
5
4
"github.com/mattn/go-tty"
6
5
)
7
6
@@ -18,22 +17,6 @@ func NewTty() (*Tty, error) {
18
17
return tty , err
19
18
}
20
19
21
- func (this * Tty ) EnableRawTty () {
22
- if this .reset == nil {
23
- Log .Warningln ("[!] Entering RAW mode (Ctrl-c will go to remote) - press Alt-r to go back to normal" )
24
- this .reset , _ = this .Raw ()
25
-
26
- // Very targeted fix for broken raw tty for non-tty output
27
- // Numbers are taken from github.com/mattn/go-tty/tty_linux.go
28
-
29
- // ioctlReadTermios
30
- termios , _ := unix .IoctlGetTermios (int (this .Input ().Fd ()), 0x5401 )
31
- termios .Oflag |= unix .OPOST
32
- // ioctlWriteTermios
33
- unix .IoctlSetTermios (int (this .Input ().Fd ()), 0x5402 , termios )
34
- }
35
- }
36
-
37
20
func (this * Tty ) DisableRawTty () {
38
21
if this .reset != nil {
39
22
Log .Infoln ("[i] Exiting RAW mode (Ctrl-c will kill the program)" )
Original file line number Diff line number Diff line change
1
+ // +build !windows
2
+
3
+
4
+ package inout
5
+
6
+ import "golang.org/x/sys/unix"
7
+
8
+ func (this * Tty ) EnableRawTty () {
9
+ if this .reset == nil {
10
+ Log .Warningln ("[!] Entering RAW mode (Ctrl-c will go to remote) - press Alt-r to go back to normal" )
11
+ this .reset , _ = this .Raw ()
12
+
13
+ // Very targeted fix for broken raw tty for non-tty output
14
+ // Numbers are taken from github.com/mattn/go-tty/tty_linux.go
15
+
16
+ // ioctlReadTermios
17
+ termios , _ := unix .IoctlGetTermios (int (this .Input ().Fd ()), 0x5401 )
18
+ termios .Oflag |= unix .OPOST
19
+ // ioctlWriteTermios
20
+ unix .IoctlSetTermios (int (this .Input ().Fd ()), 0x5402 , termios )
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ // +build windows
2
+
3
+
4
+ package inout
5
+
6
+ func (this * Tty ) EnableRawTty () {
7
+ if this .reset == nil {
8
+ Log .Warningln ("[!] Entering RAW mode (Ctrl-c will go to remote) - press Alt-r to go back to normal" )
9
+ this .reset , _ = this .Raw ()
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments