github.com/delicb/asdf-exec@v0.1.3-0.20220111003559-af5f44250ab7/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 "syscall" 7 ) 8 9 func findExecutablePath() (string, error) { 10 config, err := ConfigFromDefaultFile() 11 if err != nil { 12 return "", err 13 } 14 15 shim := os.Args[1] 16 executablePath, found, err := FindExecutable(shim, config) 17 if err != nil { 18 return "", err 19 } 20 if !found { 21 return "", fmt.Errorf("%s not found! Add default to ~/.tool-versions file", shim) 22 } 23 return executablePath, nil 24 } 25 26 func main() { 27 executable, err := findExecutablePath() 28 if err != nil { 29 fmt.Fprintln(os.Stderr, "error: "+err.Error()) 30 os.Exit(1) 31 } 32 33 args := []string{executable} 34 args = append(args, os.Args[2:]...) 35 syscall.Exec(executable, args, os.Environ()) 36 }