fix: allow non absolute paths to be executed

this is a regression introduced in 06272778f8
dev
TorchedSammy 2021-11-22 22:49:23 -05:00
parent 4127396892
commit 80dcfc362b
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 7 additions and 0 deletions

View File

@ -166,6 +166,13 @@ func execCommand(cmd string) error {
// custom lookpath function so we know if a command is found *and* has execute permission // custom lookpath function so we know if a command is found *and* has execute permission
func lookpath(file string) error { func lookpath(file string) error {
skip := []string{"./", "/", "../", "~/"}
for _, s := range skip {
if strings.HasPrefix(file, s) {
err := findExecutable(file)
return err
}
}
for _, dir := range filepath.SplitList(os.Getenv("PATH")) { for _, dir := range filepath.SplitList(os.Getenv("PATH")) {
path := filepath.Join(dir, file) path := filepath.Join(dir, file)
err := findExecutable(path) err := findExecutable(path)