os/exec: add GODEBUG setting to opt out of ErrDot changes

The changes are likely to break users, and we need
to make it easy to unbreak without code changes.

For #43724.
Fixes #53962.

Change-Id: I105c5d6c801d354467e0cefd268189c18846858e
Reviewed-on: https://go-review.googlesource.com/c/go/+/419794
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
This commit is contained in:
Russ Cox 2022-07-27 14:36:05 -04:00
parent 462b78fe70
commit 027855e8d8
6 changed files with 68 additions and 37 deletions

View file

@ -8,6 +8,7 @@ package exec
import (
"errors"
"internal/godebug"
"io/fs"
"os"
"path/filepath"
@ -56,7 +57,7 @@ func LookPath(file string) (string, error) {
}
path := filepath.Join(dir, file)
if err := findExecutable(path); err == nil {
if !filepath.IsAbs(path) {
if !filepath.IsAbs(path) && godebug.Get("execerrdot") != "0" {
return path, &Error{file, ErrDot}
}
return path, nil