Skip to content

Commit bd96138

Browse files
authored
Merge pull request #67 from samalba/terminal-bash
env.Terminal: defaults to bash when available
2 parents 7f07dd7 + 3e23bfb commit bd96138

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

environment/environment.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,14 @@ func (env *Environment) Terminal(ctx context.Context) error {
519519
container := env.container
520520
// In case there's bash in the container, show the same pretty PS1 as for the default /bin/sh terminal in dagger
521521
container = container.WithNewFile("/root/.bash_aliases", `export PS1="\033[33mdagger\033[0m \033[02m\$(pwd | sed \"s|^\$HOME|~|\")\033[0m \$ "`+"\n")
522-
if _, err := container.Terminal(dagger.ContainerTerminalOpts{}).Sync(ctx); err != nil {
522+
defaultShell := []string{}
523+
// Check if bash is available
524+
if _, err := container.WithExec([]string{"grep", "/bash", "/etc/shells"}).Sync(ctx); err == nil {
525+
defaultShell = []string{"bash"}
526+
}
527+
if _, err := container.Terminal(dagger.ContainerTerminalOpts{
528+
Cmd: defaultShell,
529+
}).Sync(ctx); err != nil {
523530
return err
524531
}
525532
return nil

0 commit comments

Comments
 (0)