Skip to content

Commit f40c04f

Browse files
committed
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.
1 parent eff336d commit f40c04f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

internal/subshell/subshell.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,27 @@ func detectShellParent() string {
251251
multilog.Error("Failed to get parent process: %s", errs.JoinMessage(err))
252252
}
253253

254+
shell := ""
254255
for p != nil && p.Pid != 0 {
255256
name, err := p.Name()
256257
if err == nil {
257258
if strings.Contains(name, string(filepath.Separator)) {
258259
name = path.Base(name)
259260
}
260261
if supportedShellName(name) {
261-
return name
262+
if runtime.GOOS == "darwin" && name == bash.Name && shell == "" {
263+
// The installer starts State Tool after installing it. The user typically invokes the
264+
// installer using the one-line shell command. The one-liner tends to end up in bash,
265+
// which is often not the user's default on macOS. Try looking one level up for the
266+
// correct shell.
267+
shell = name
268+
} else {
269+
return name
270+
}
262271
}
263272
}
264273
p, _ = p.Parent()
265274
}
266275

267-
return ""
276+
return shell
268277
}

0 commit comments

Comments
 (0)