From 9dc1290215f8ab91be20c67410eedf4dc95a5c64 Mon Sep 17 00:00:00 2001 From: Ethan Mick Date: Tue, 23 Jan 2018 20:06:50 -0500 Subject: [PATCH] Fix error message compare As explained here: https://github.com/mitchellh/go-homedir/issues/18 The exec.ErrNotFound error is returned, but this error is wrapped by exec.Error() so the returned error will never be exec.ErrNotFound. --- homedir.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homedir.go b/homedir.go index 47e1f9e..b14ec48 100644 --- a/homedir.go +++ b/homedir.go @@ -88,7 +88,7 @@ func dirUnix() (string, error) { cmd.Stdout = &stdout if err := cmd.Run(); err != nil { // If the error is ErrNotFound, we ignore it. Otherwise, return it. - if err != exec.ErrNotFound { + if strings.HasSufix(err.Error(), err.ErrNotFound.Error()) { return "", err } } else {