Check the chosen command for existence

This commit is contained in:
2021-11-21 16:30:57 +10:30
parent 0bfa38fff5
commit 14a35cdd9e
2 changed files with 9 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"log"
"os"
"os/exec"
"strings"
"gopkg.in/yaml.v2"
@@ -147,6 +148,12 @@ func (c *Config) UpdateFromJSON(j []byte) error {
}
}
// check the command exists
_, err := exec.LookPath(newConfig.DownloadProfiles[i].Command)
if err != nil {
return fmt.Errorf("Could not find %s on the path", newConfig.DownloadProfiles[i].Command)
}
}
*c = newConfig