mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Revert "os/exec: return error when PATH lookup would use current directory"
This reverts CL 381374. Reason for revert: broke tests for x/sys/execabs. Updates #43724. Updates #43947. Change-Id: I9eb3adb5728dead66dbd20f6afe1e7a77e2a26f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/403058 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
2278a51fa0
commit
f2b674756b
13 changed files with 173 additions and 249 deletions
|
|
@ -31,11 +31,7 @@ func findExecutable(file string) error {
|
|||
// LookPath searches for an executable named file in the
|
||||
// directories named by the PATH environment variable.
|
||||
// If file contains a slash, it is tried directly and the PATH is not consulted.
|
||||
// Otherwise, on success, the result is an absolute path.
|
||||
//
|
||||
// In older versions of Go, LookPath could return a path relative to the current directory.
|
||||
// As of Go 1.19, LookPath will instead return that path along with an error satisfying
|
||||
// errors.Is(err, ErrDot). See the package documentation for more details.
|
||||
// The result may be an absolute path or a path relative to the current directory.
|
||||
func LookPath(file string) (string, error) {
|
||||
// NOTE(rsc): I wish we could use the Plan 9 behavior here
|
||||
// (only bypass the path if file begins with / or ./ or ../)
|
||||
|
|
@ -56,9 +52,6 @@ func LookPath(file string) (string, error) {
|
|||
}
|
||||
path := filepath.Join(dir, file)
|
||||
if err := findExecutable(path); err == nil {
|
||||
if !filepath.IsAbs(path) {
|
||||
return path, &Error{file, ErrDot}
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue