From eff336d9b31b6245bc08003eb84a8492be22ce00 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 15 Apr 2025 16:38:18 -0400 Subject: [PATCH 1/3] subshell.DetectShell should default to zsh on macOS. --- internal/subshell/subshell_darwin.go | 34 +++++++++++++++++++ ...{subshell_lin_mac.go => subshell_linux.go} | 4 +-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 internal/subshell/subshell_darwin.go rename internal/subshell/{subshell_lin_mac.go => subshell_linux.go} (94%) diff --git a/internal/subshell/subshell_darwin.go b/internal/subshell/subshell_darwin.go new file mode 100644 index 0000000000..2a96301e08 --- /dev/null +++ b/internal/subshell/subshell_darwin.go @@ -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 +} diff --git a/internal/subshell/subshell_lin_mac.go b/internal/subshell/subshell_linux.go similarity index 94% rename from internal/subshell/subshell_lin_mac.go rename to internal/subshell/subshell_linux.go index 9a666e16cb..8b4bf1563f 100644 --- a/internal/subshell/subshell_lin_mac.go +++ b/internal/subshell/subshell_linux.go @@ -1,5 +1,5 @@ -//go:build !windows -// +build !windows +//go:build linux +// +build linux package subshell From f40c04fc5268176223ba23a477346565c5e013e7 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 15 Apr 2025 18:05:57 -0400 Subject: [PATCH 2/3] Correctly detect the user's shell after invoking the one-line installer command. When running the one-line installer, it executes in sh, which is most likely not the user's actual shell. --- internal/subshell/subshell.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/subshell/subshell.go b/internal/subshell/subshell.go index 8844de8e69..f547a1b865 100644 --- a/internal/subshell/subshell.go +++ b/internal/subshell/subshell.go @@ -251,6 +251,7 @@ 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 { @@ -258,11 +259,19 @@ func detectShellParent() string { 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 } From e50ebd591a80192ba6222557ace7e5372a5e4bd4 Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 16 Apr 2025 10:16:13 -0400 Subject: [PATCH 3/3] Update to go 1.23.8 to address CVEs. --- .github/workflows/build.yml | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 85e57314f8..88aecb9f2a 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: strategy: matrix: go-version: - - 1.23.7 + - 1.23.8 sys: - {os: ubuntu-latest} - {os: macos-13, shell: zsh} diff --git a/go.mod b/go.mod index d83833829c..2175443abd 100644 --- a/go.mod +++ b/go.mod @@ -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