Skip to content

Commit fcb586f

Browse files
fixing --shell on alpine
1 parent a066e7a commit fcb586f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/dockerized.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,21 @@ func main() {
145145
}
146146
welcomeMessage = strings.ReplaceAll(welcomeMessage, "\\", "\\\\")
147147

148-
preferredShells := "bash zsh sh"
148+
shells := []string{
149+
"bash",
150+
"zsh",
151+
"sh",
152+
}
153+
var shellDetectionCommands []string
154+
for _, shell := range shells {
155+
shellDetectionCommands = append(shellDetectionCommands, "command -v "+shell)
156+
}
157+
for _, shell := range shells {
158+
shellDetectionCommands = append(shellDetectionCommands, "which "+shell)
159+
}
160+
149161
var cmdPrintWelcome = fmt.Sprintf("echo '%s'", color.YellowString(welcomeMessage))
150-
var cmdLaunchShell = fmt.Sprintf("$(command -pv %[1]s | head -n1 || which %[1]s | head -n1)", preferredShells)
162+
var cmdLaunchShell = fmt.Sprintf("$(%s)", strings.Join(shellDetectionCommands, " || "))
151163

152164
runOptions.Environment = append(runOptions.Environment, "PS1="+ps1)
153165
runOptions.Entrypoint = []string{"/bin/sh"}

0 commit comments

Comments
 (0)