Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Execute exec commands in sh #75

Merged
merged 1 commit into from
Jul 27, 2020
Merged
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
18 changes: 8 additions & 10 deletions cmd/coder/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"os"
"os/signal"
"strings"
"time"

"github.com/spf13/pflag"
Expand Down Expand Up @@ -79,19 +80,16 @@ func (cmd *shellCmd) Run(fl *pflag.FlagSet) {
}
var (
envName = fl.Arg(0)
command = fl.Arg(1)
ctx = context.Background()
)

var args []string
if command != "" {
args = fl.Args()[2:]
}

// Bring user into shell if no command is specified.
if command == "" {
command = "sh"
args = []string{"-c", "exec $(getent passwd $(whoami) | awk -F: '{ print $7 }')"}
command := "sh"
args := []string{"-c"}
if len(fl.Args()) > 1 {
args = append(args, strings.Join(fl.Args()[1:], " "))
} else {
// Bring user into shell if no command is specified.
args = append(args, "exec $(getent passwd $(whoami) | awk -F: '{ print $7 }')")
}

err := runCommand(ctx, envName, command, args)
Expand Down