Skip to content

Commit

Permalink
tidy up args handling and duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbednarz committed Sep 16, 2020
1 parent dfc7549 commit 038f775
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ var execCmd = &cobra.Command{
},
Run: func(cmd *cobra.Command, args []string) {
profileName := args[0]
// Remove the extra executable name at the beginning of the slice.
copy(args[0:], args[0+1:])
args[len(args)-1] = ""
args = args[:len(args)-1]

log.Debug("using profile: ", profileName)

home, err := homedir.Dir()
Expand Down Expand Up @@ -59,12 +64,6 @@ var execCmd = &cobra.Command{
log.Fatalf("couldn't find the executable '%s': %w", executable, err)
}

log.Printf("found executable %s", argv0)

// Remove the extra executable name at the beginning of the slice.
copy(args[0:], args[0+1:])
args[len(args)-1] = ""
args = args[:len(args)-1]

runningCommand := exec.Command(executable, args...)
runningCommand.Env = append(os.Environ(),
Expand Down

0 comments on commit 038f775

Please sign in to comment.