A virtual jailed shell environment for Go apps backed by an io/fs#FS.
1package command
2
3import (
4 "context"
5 "io"
6
7 "github.com/go-git/go-billy/v5"
8 "mvdan.cc/sh/v3/expand"
9 "mvdan.cc/sh/v3/interp"
10)
11
12type ExecContext struct {
13 Stdin io.Reader
14 Stdout, Stderr io.Writer
15 Dir string
16 Environ expand.Environ
17 FS billy.Filesystem
18 // Runner is the active shell runner. Commands that need to dispatch a
19 // child command (for example, `time CMD`) should call Runner.Subshell()
20 // and re-enter the shell so the call goes through the same exec handler
21 // chain instead of poking at the registry directly. May be nil in
22 // embedders or tests that have not wired up a runner.
23 Runner *interp.Runner
24}
25
26type Execer interface {
27 Exec(ctx context.Context, ec *ExecContext, args []string) error
28}