diff --git a/internal/lookup/device.go b/internal/lookup/device.go index 29738cc7..aa4a2120 100644 --- a/internal/lookup/device.go +++ b/internal/lookup/device.go @@ -19,7 +19,6 @@ package lookup import ( "fmt" "os" - "path/filepath" "github.com/sirupsen/logrus" ) @@ -33,7 +32,7 @@ const ( func NewCharDeviceLocator(logger *logrus.Logger, root string) Locator { l := file{ logger: logger, - prefixes: []string{root, filepath.Join(root, devRoot)}, + prefixes: getSearchPrefixes(root, "", devRoot), filter: assertCharDevice, } diff --git a/internal/lookup/dir.go b/internal/lookup/dir.go index 695025a5..f1d0156c 100644 --- a/internal/lookup/dir.go +++ b/internal/lookup/dir.go @@ -28,7 +28,7 @@ import ( func NewDirectoryLocator(logger *log.Logger, root string) Locator { l := file{ logger: logger, - prefixes: []string{root}, + prefixes: getSearchPrefixes(root), filter: assertDirectory, } diff --git a/internal/lookup/executable.go b/internal/lookup/executable.go index d347732c..ac27634b 100644 --- a/internal/lookup/executable.go +++ b/internal/lookup/executable.go @@ -19,7 +19,6 @@ package lookup import ( "fmt" "os" - "path/filepath" "strings" log "github.com/sirupsen/logrus" @@ -37,14 +36,10 @@ func NewExecutableLocator(logger *log.Logger, root string) Locator { } func newExecutableLocator(logger *log.Logger, root string, paths ...string) *executable { - var prefixes []string - for _, dir := range paths { - prefixes = append(prefixes, filepath.Join(root, dir)) - } l := executable{ file: file{ logger: logger, - prefixes: prefixes, + prefixes: getSearchPrefixes(root, paths...), filter: assertExecutable, }, } diff --git a/internal/lookup/executable_test.go b/internal/lookup/executable_test.go index 68d7c678..09bbf2d9 100644 --- a/internal/lookup/executable_test.go +++ b/internal/lookup/executable_test.go @@ -34,7 +34,7 @@ func TestExecutableLocator(t *testing.T) { }{ { root: "", - expectedPrefixes: nil, + expectedPrefixes: []string{""}, }, { root: "", @@ -48,7 +48,7 @@ func TestExecutableLocator(t *testing.T) { }, { root: "/", - expectedPrefixes: nil, + expectedPrefixes: []string{"/"}, }, { root: "/",