diff --git a/program.go b/program.go index 4e42902..39ef2e3 100644 --- a/program.go +++ b/program.go @@ -3,6 +3,7 @@ package process import ( "bytes" "context" + "path/filepath" "strconv" "dappco.re/go/core" @@ -36,6 +37,12 @@ func (p *Program) Find() error { if err != nil { return core.E("program.find", core.Concat(strconv.Quote(p.Name), ": not found in PATH"), ErrProgramNotFound) } + if !filepath.IsAbs(path) { + path, err = filepath.Abs(path) + if err != nil { + return core.E("program.find", core.Concat(strconv.Quote(p.Name), ": failed to resolve absolute path"), err) + } + } p.Path = path return nil } diff --git a/program_test.go b/program_test.go index d6dd7fa..fcadef7 100644 --- a/program_test.go +++ b/program_test.go @@ -3,6 +3,7 @@ package process_test import ( "context" "os" + "path/filepath" "testing" "time" @@ -24,6 +25,7 @@ func TestProgram_Find_Good(t *testing.T) { p := &process.Program{Name: "echo"} require.NoError(t, p.Find()) assert.NotEmpty(t, p.Path) + assert.True(t, filepath.IsAbs(p.Path)) } func TestProgram_FindUnknown_Bad(t *testing.T) {