Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit e341e28

Browse files
committed
Set output correctly
Change-Id: Idc792af25471e7becbac8facd27eb149cfd8514a
1 parent 386bb22 commit e341e28

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

cmd/coder/shell.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,21 @@ func runCommand(ctx context.Context, envName string, command string, args []stri
9595
env = findEnv(entClient, envName)
9696
)
9797

98-
termfd := os.Stdin.Fd()
98+
termfd := os.Stdout.Fd()
9999

100100
tty := terminal.IsTerminal(int(termfd))
101101
if tty {
102-
state, err := xterminal.MakeRaw(termfd)
102+
stdinState, err := xterminal.MakeRaw(os.Stdin.Fd())
103103
if err != nil {
104104
return err
105105
}
106-
defer func() {
107-
err := xterminal.Restore(termfd, state)
108-
if err != nil {
109-
flog.Error("restore term state: %v", err)
110-
}
111-
}()
106+
defer xterminal.Restore(os.Stdin.Fd(), stdinState)
107+
108+
stdoutState, err := xterminal.MakeOutputRaw(os.Stdout.Fd())
109+
if err != nil {
110+
return err
111+
}
112+
defer xterminal.Restore(os.Stdout.Fd(), stdoutState)
112113
}
113114

114115
ctx, cancel := context.WithCancel(ctx)
@@ -120,13 +121,18 @@ func runCommand(ctx context.Context, envName string, command string, args []stri
120121
}
121122
go heartbeat(ctx, conn, 15*time.Second)
122123

124+
term := os.Getenv("TERM")
125+
if term == "" {
126+
term = "xterm" // TODO: fix this
127+
}
128+
123129
execer := wsep.RemoteExecer(conn)
124130
process, err := execer.Start(ctx, wsep.Command{
125131
Command: command,
126132
Args: args,
127133
TTY: tty,
128134
Stdin: true,
129-
Env: []string{"TERM=" + os.Getenv("TERM")},
135+
Env: []string{"TERM=" + term},
130136
})
131137
if err != nil {
132138
return err

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module cdr.dev/coder-cli
33
go 1.14
44

55
require (
6-
cdr.dev/wsep v0.0.0-20200727194627-13ef1f8df965
6+
cdr.dev/wsep v0.0.0-20200728004104-4f85e914f20c
77
github.com/fatih/color v1.9.0 // indirect
88
github.com/gorilla/websocket v1.4.1
99
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cdr.dev/slog v1.3.0 h1:MYN1BChIaVEGxdS7I5cpdyMC0+WfJfK8BETAfzfLUGQ=
22
cdr.dev/slog v1.3.0/go.mod h1:C5OL99WyuOK8YHZdYY57dAPN1jK2WJlCdq2VP6xeQns=
3-
cdr.dev/wsep v0.0.0-20200727194627-13ef1f8df965 h1:zFpraxgmcgX60oWFs8r1moWFMJ0x945t4moxNb6fjJ8=
4-
cdr.dev/wsep v0.0.0-20200727194627-13ef1f8df965/go.mod h1:N20HJdMn6q9NG7sjxL4uYdBQBGOf8/6psfdMyuJnYw8=
3+
cdr.dev/wsep v0.0.0-20200728004104-4f85e914f20c h1:opj4lhqu4wdFQEeoDw2GVp5SB+NxRnMkS8H62kodF1k=
4+
cdr.dev/wsep v0.0.0-20200728004104-4f85e914f20c/go.mod h1:2VKClUml3gfmLez0gBxTJIjSKszpQotc2ZqPdApfK/Y=
55
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
66
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
77
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
@@ -107,8 +107,6 @@ github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
107107
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
108108
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
109109
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
110-
github.com/iamacarpet/go-winpty v1.0.2 h1:jwPVTYrjAHZx6Mcm6K5i9G4opMp5TblEHH5EQCl/Gzw=
111-
github.com/iamacarpet/go-winpty v1.0.2/go.mod h1:/GHKJicG/EVRQIK1IQikMYBakBkhj/3hTjLgdzYsmpI=
112110
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
113111
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
114112
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=

0 commit comments

Comments
 (0)