mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
os/exec: document that LookPath's result may be a relative path
Fixes #3622 R=golang-dev, alex.brainman CC=golang-dev https://golang.org/cl/12971043
This commit is contained in:
parent
15e6ce2351
commit
a41a5bb207
3 changed files with 3 additions and 0 deletions
|
|
@ -28,6 +28,7 @@ func findExecutable(file string) error {
|
||||||
// in the directories named by the path environment variable.
|
// in the directories named by the path environment variable.
|
||||||
// If file begins with "/", "#", "./", or "../", it is tried
|
// If file begins with "/", "#", "./", or "../", it is tried
|
||||||
// directly and the path is not consulted.
|
// directly and the path is not consulted.
|
||||||
|
// The result may be an absolute path or a path relative to the current directory.
|
||||||
func LookPath(file string) (string, error) {
|
func LookPath(file string) (string, error) {
|
||||||
// skip the path lookup for these prefixes
|
// skip the path lookup for these prefixes
|
||||||
skip := []string{"/", "#", "./", "../"}
|
skip := []string{"/", "#", "./", "../"}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ func findExecutable(file string) error {
|
||||||
// LookPath searches for an executable binary named file
|
// LookPath searches for an executable binary named file
|
||||||
// in the directories named by the PATH environment variable.
|
// in the directories named by the PATH environment variable.
|
||||||
// If file contains a slash, it is tried directly and the PATH is not consulted.
|
// If file contains a slash, it is tried directly and the PATH is not consulted.
|
||||||
|
// The result may be an absolute path or a path relative to the current directory.
|
||||||
func LookPath(file string) (string, error) {
|
func LookPath(file string) (string, error) {
|
||||||
// NOTE(rsc): I wish we could use the Plan 9 behavior here
|
// NOTE(rsc): I wish we could use the Plan 9 behavior here
|
||||||
// (only bypass the path if file begins with / or ./ or ../)
|
// (only bypass the path if file begins with / or ./ or ../)
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ func findExecutable(file string, exts []string) (string, error) {
|
||||||
// If file contains a slash, it is tried directly and the PATH is not consulted.
|
// If file contains a slash, it is tried directly and the PATH is not consulted.
|
||||||
// LookPath also uses PATHEXT environment variable to match
|
// LookPath also uses PATHEXT environment variable to match
|
||||||
// a suitable candidate.
|
// a suitable candidate.
|
||||||
|
// The result may be an absolute path or a path relative to the current directory.
|
||||||
func LookPath(file string) (f string, err error) {
|
func LookPath(file string) (f string, err error) {
|
||||||
x := os.Getenv(`PATHEXT`)
|
x := os.Getenv(`PATHEXT`)
|
||||||
if x == `` {
|
if x == `` {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue