Skip to content

Commit

Permalink
Revert "Make the exec command default to a login shell. Fixes #546"
Browse files Browse the repository at this point in the history
This reverts commit 8ad90a6.
This reverts commit 38262fd.
  • Loading branch information
mtibben committed Apr 30, 2020
1 parent 255e9cb commit 2eaabb9
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions cli/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
osexec "os/exec"
"os/signal"
"path/filepath"
"runtime"
"strings"
"syscall"
Expand Down Expand Up @@ -85,6 +84,7 @@ func ConfigureExecCommand(app *kingpin.Application) {
StringVar(&input.ProfileName)

cmd.Arg("cmd", "Command to execute, defaults to $SHELL").
Default(os.Getenv("SHELL")).
StringVar(&input.Command)

cmd.Arg("args", "Command arguments").
Expand All @@ -95,36 +95,11 @@ func ConfigureExecCommand(app *kingpin.Application) {
input.Config.MfaPromptMethod = GlobalFlags.PromptDriver
input.Config.NonChainedGetSessionTokenDuration = input.SessionDuration
input.Config.AssumeRoleDuration = input.SessionDuration
if input.Command == "" {
input.Command, input.Args = getDefaultShellCmd()
}
if input.Command == "" {
app.Fatalf("Argument 'cmd' not provided, and SHELL not present, try --help")
}
app.FatalIfError(ExecCommand(input), "")
return nil
})
}

func getDefaultShellCmd() (string, []string) {
shellCmd := os.Getenv("SHELL")
s := strings.ToLower(shellCmd)
s = strings.TrimSuffix(s, ".exe")
s = filepath.Base(s)

// for shells that support it start an interactive login shell
shellArgs := []string{}
if s == "sh" ||
s == "bash" ||
s == "zsh" ||
s == "csh" ||
s == "fish" {
shellArgs = []string{"-l"}
}

return shellCmd, shellArgs
}

func ExecCommand(input ExecCommandInput) error {
if os.Getenv("AWS_VAULT") != "" {
return fmt.Errorf("aws-vault sessions should be nested with care, unset $AWS_VAULT to force")
Expand Down

0 comments on commit 2eaabb9

Please sign in to comment.