From 34a0ab98376ca06920c7dad3f26995b33a2fa026 Mon Sep 17 00:00:00 2001 From: Nimesh Silva Date: Fri, 4 Oct 2024 17:49:12 +1000 Subject: [PATCH] Add "./" to the path for backward compatibility for executables in current directory --- lib/procmngt/procmngt.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/procmngt/procmngt.go b/lib/procmngt/procmngt.go index 6113378..22e67fc 100644 --- a/lib/procmngt/procmngt.go +++ b/lib/procmngt/procmngt.go @@ -8,6 +8,7 @@ package procmngt import ( + "errors" "io" "os/exec" "sync" @@ -106,6 +107,16 @@ func (tc timeoutExecutable) Execute(terminate <-chan struct{}) (exitCode int, er } func NewExecutable(execConf ExecConfig) Executable { + + // Go 1.19+ requires "./" for executables in the current directory. + // Add "./" to the path for backward compatibility with `Silver` config files + // that don't have it for executables in the current directory. + // golang issue: https://github.com/golang/go/issues/43724 + _, err := exec.LookPath(execConf.Path) + if errors.Is(err, exec.ErrDot) { + execConf.Path = "./" + execConf.Path + } + var e Executable e = executable{ cmd: setupCmd(execConf),