diff --git a/cli/exec.go b/cli/exec.go index cf97b43cc..343974916 100644 --- a/cli/exec.go +++ b/cli/exec.go @@ -7,7 +7,6 @@ import ( "os" osexec "os/exec" "os/signal" - "path/filepath" "runtime" "strings" "syscall" @@ -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"). @@ -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")