MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / run

Method run

internal/sshserver/testSessionChannel.go:175–205  ·  view source on GitHub ↗
(argv []string, stdout io.Writer, stderr io.Writer, exitWithError bool)

Source from the content-addressed store, hash-verified

173}
174
175func (t *testSessionChannel) run(argv []string, stdout io.Writer, stderr io.Writer, exitWithError bool) (err error) {
176 switch argv[0] {
177 case "echo":
178 _, err = stdout.Write([]byte(strings.Join(argv[1:], " ") + "\n"))
179 case "tput":
180 if len(argv) > 2 || (argv[1] != "cols" && argv[1] != "rows") {
181 _, err = stderr.Write([]byte("Usage: tput [rows|cols]"))
182 if exitWithError {
183 return fmt.Errorf("usage: tput [rows|cols]")
184 }
185 } else if !t.pty {
186 _, err = stderr.Write([]byte("Stdout is not a TTY"))
187 if exitWithError {
188 return fmt.Errorf("usage: tput [rows|cols]")
189 }
190 } else {
191 switch argv[1] {
192 case "cols":
193 _, err = stdout.Write([]byte(fmt.Sprintf("%d\n", t.columns)))
194 case "rows":
195 _, err = stdout.Write([]byte(fmt.Sprintf("%d\n", t.rows)))
196 }
197 }
198 default:
199 _, err = stderr.Write([]byte(fmt.Sprintf("unknown program: %s", argv[0])))
200 if exitWithError {
201 return fmt.Errorf("unknown program: %s", argv[0])
202 }
203 }
204 return err
205}
206
207func (t *testSessionChannel) OnSignal(
208 _ uint64,

Callers 2

OnExecRequestMethod · 0.95
OnShellMethod · 0.95

Calls 2

WriteMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected