Skip to content

Commit

Permalink
Merge pull request #30 from lawrencegripper/lg/defaulttobash
Browse files Browse the repository at this point in the history
Default to /bin/bash on exec
  • Loading branch information
stuartleeks committed Nov 16, 2020
2 parents d6baa3f + 9326eac commit 42553ea
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/devcontainer/devcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,20 @@ func createListCommand() *cobra.Command {

func createExecCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "exec DEVCONTAINER_NAME COMMAND [args...]",
Use: "exec DEVCONTAINER_NAME COMMAND [args...] (args will default to /bin/bash if none provided)",
Short: "Execute a command in a devcontainer",
Long: "Execute a command in a devcontainer, similar to `docker exec`. Pass `?` as DEVCONTAINER_NAME to be prompted.",
RunE: func(cmd *cobra.Command, args []string) error {

if len(args) < 2 {
if len(args) < 1 {
return cmd.Usage()
}

// Default to executing /bin/bash
if (len(args) == 1) {
args = append(args, "/bin/bash")
}

devcontainerName := args[0]
devcontainerList, err := devcontainers.ListDevcontainers()
if err != nil {
Expand Down

0 comments on commit 42553ea

Please sign in to comment.