execabs: make safe for Go 1.19

To preserve the same errors that LookPath used to return,
LookPath needs to know to ignore the new Go 1.19 exec.ErrDot errors.

For golang/go#43724.

Change-Id: I8938813a1a4e14bf697f05879e3ab212611644da
Reviewed-on: https://go-review.googlesource.com/c/sys/+/403256
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/execabs/execabs.go b/execabs/execabs.go
index 7819249..b981cfb 100644
--- a/execabs/execabs.go
+++ b/execabs/execabs.go
@@ -53,7 +53,7 @@
 // LookPath instead returns an error.
 func LookPath(file string) (string, error) {
 	path, err := exec.LookPath(file)
-	if err != nil {
+	if err != nil && !isGo119ErrDot(err) {
 		return "", err
 	}
 	if filepath.Base(file) == file && !filepath.IsAbs(path) {
diff --git a/execabs/execabs_go118.go b/execabs/execabs_go118.go
new file mode 100644
index 0000000..23f4d6e
--- /dev/null
+++ b/execabs/execabs_go118.go
@@ -0,0 +1,11 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build !go1.19
+
+package execabs
+
+func isGo119ErrDot(err error) bool {
+	return false
+}
diff --git a/execabs/execabs_go119.go b/execabs/execabs_go119.go
new file mode 100644
index 0000000..6db6819
--- /dev/null
+++ b/execabs/execabs_go119.go
@@ -0,0 +1,14 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build go1.19
+
+package execabs
+
+import "strings"
+
+func isGo119ErrDot(err error) bool {
+	// TODO: return errors.Is(err, exec.ErrDot)
+	return strings.Contains(err.Error(), "current directory")
+}