Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
matrix:
go-version:
- 1.23.7
- 1.23.8
sys:
- {os: ubuntu-latest}
- {os: macos-13, shell: zsh}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ActiveState/cli

go 1.23.7
go 1.23.8

require (
github.com/99designs/gqlgen v0.17.54
Expand Down
13 changes: 11 additions & 2 deletions internal/subshell/subshell.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,27 @@ func detectShellParent() string {
multilog.Error("Failed to get parent process: %s", errs.JoinMessage(err))
}

shell := ""
for p != nil && p.Pid != 0 {
name, err := p.Name()
if err == nil {
if strings.Contains(name, string(filepath.Separator)) {
name = path.Base(name)
}
if supportedShellName(name) {
return name
if runtime.GOOS == "darwin" && name == bash.Name && shell == "" {
// The installer starts State Tool after installing it. The user typically invokes the
// installer using the one-line shell command. The one-liner tends to end up in bash,
// which is often not the user's default on macOS. Try looking one level up for the
// correct shell.
shell = name
} else {
return name
}
}
}
p, _ = p.Parent()
}

return ""
return shell
}
34 changes: 34 additions & 0 deletions internal/subshell/subshell_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//go:build darwin
// +build darwin

package subshell

import (
"strings"

"github.com/ActiveState/cli/internal/subshell/bash"
"github.com/ActiveState/cli/internal/subshell/fish"
"github.com/ActiveState/cli/internal/subshell/tcsh"
"github.com/ActiveState/cli/internal/subshell/zsh"
)

var supportedShells = []SubShell{
&bash.SubShell{},
&zsh.SubShell{},
&tcsh.SubShell{},
&fish.SubShell{},
}

const (
SHELL_ENV_VAR = "SHELL"
OS_DEFAULT = "zsh"
)

func supportedShellName(filename string) bool {
for _, subshell := range supportedShells {
if strings.EqualFold(filename, subshell.Shell()) {
return true
}
}
return false
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !windows
// +build !windows
//go:build linux
// +build linux

package subshell

Expand Down