Skip to content

Commit 22c8db3

Browse files
committed
Do not start subshell if not interactive
1 parent c3ed7de commit 22c8db3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

cmd/state-installer/cmd.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/ActiveState/cli/pkg/cmdlets/errors"
3333
"github.com/ActiveState/cli/pkg/project"
3434
"github.com/ActiveState/cli/pkg/sysinfo"
35+
"golang.org/x/crypto/ssh/terminal"
3536
)
3637

3738
const AnalyticsCat = "installer"
@@ -44,6 +45,7 @@ type Params struct {
4445
command string
4546
force bool
4647
isUpdate bool
48+
isInteractive bool
4749
activate *project.Namespaced
4850
activateDefault *project.Namespaced
4951
}
@@ -126,6 +128,7 @@ func main() {
126128
an.Event(AnalyticsFunnelCat, "start")
127129

128130
params := newParams()
131+
params.isInteractive = terminal.IsTerminal(int(os.Stdin.Fd()))
129132
cmd := captain.NewCommand(
130133
"state-installer",
131134
"",
@@ -386,7 +389,7 @@ func postInstallEvents(out output.Outputer, cfg *config.Instance, an analytics.D
386389
an.EventWithLabel(AnalyticsFunnelCat, "forward-activate-default-err", err.Error())
387390
return errs.Silence(errs.Wrap(err, "Could not activate %s, error returned: %s", params.activateDefault.String(), errs.JoinMessage(err)))
388391
}
389-
case !params.isUpdate && os.Getenv(constants.InstallerNoSubshell) != "true":
392+
case !params.isUpdate && params.isInteractive && os.Getenv(constants.InstallerNoSubshell) != "true":
390393
ss := subshell.New(cfg)
391394
ss.SetEnv(osutils.InheritEnv(envMap(binPath)))
392395
if err := ss.Activate(nil, cfg, out); err != nil {

0 commit comments

Comments
 (0)