mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
os/exec: remove "binary" when talking about executables
The use of binary was incorrect as executable files can also be scripts. The docs for Error are also reworded. The old docs implied that Error was returned when attempting to start an executable, which is not correct: it was returned by LookPath when the file was not found or did not have the attributes of an executable. Change-Id: I757a44b16612936df4498b43c45c12e4c14956d2 Reviewed-on: https://go-review.googlesource.com/90315 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
d0925228d7
commit
155aefe0c1
5 changed files with 16 additions and 14 deletions
|
|
@ -34,10 +34,12 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Error records the name of a binary that failed to be executed
|
// Error is returned by LookPath when it fails to classify a file as an
|
||||||
// and the reason it failed.
|
// executable.
|
||||||
type Error struct {
|
type Error struct {
|
||||||
|
// Name is the file name for which the error occurred.
|
||||||
Name string
|
Name string
|
||||||
|
// Err is the underlying error.
|
||||||
Err error
|
Err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,11 +142,11 @@ func TestCatGoodAndBadFile(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoExistBinary(t *testing.T) {
|
func TestNoExistExecutable(t *testing.T) {
|
||||||
// Can't run a non-existent binary
|
// Can't run a non-existent executable
|
||||||
err := exec.Command("/no-exist-binary").Run()
|
err := exec.Command("/no-exist-executable").Run()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("expected error from /no-exist-binary")
|
t.Error("expected error from /no-exist-executable")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -334,7 +334,7 @@ func TestPipeLookPathLeak(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < 6; i++ {
|
for i := 0; i < 6; i++ {
|
||||||
cmd := exec.Command("something-that-does-not-exist-binary")
|
cmd := exec.Command("something-that-does-not-exist-executable")
|
||||||
cmd.StdoutPipe()
|
cmd.StdoutPipe()
|
||||||
cmd.StderrPipe()
|
cmd.StderrPipe()
|
||||||
cmd.StdinPipe()
|
cmd.StdinPipe()
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ func findExecutable(file string) error {
|
||||||
return os.ErrPermission
|
return os.ErrPermission
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookPath searches for an executable binary named file
|
// LookPath searches for an executable named file in the
|
||||||
// in the directories named by the path environment variable.
|
// 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.
|
// The result may be an absolute path or a path relative to the current directory.
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ func findExecutable(file string) error {
|
||||||
return os.ErrPermission
|
return os.ErrPermission
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookPath searches for an executable binary named file
|
// LookPath searches for an executable named file in the
|
||||||
// in the directories named by the PATH environment variable.
|
// 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.
|
// 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) {
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ func findExecutable(file string, exts []string) (string, error) {
|
||||||
return "", os.ErrNotExist
|
return "", os.ErrNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookPath searches for an executable binary named file
|
// LookPath searches for an executable named file in the
|
||||||
// in the directories named by the PATH environment variable.
|
// 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.
|
||||||
// LookPath also uses PATHEXT environment variable to match
|
// LookPath also uses PATHEXT environment variable to match
|
||||||
// a suitable candidate.
|
// a suitable candidate.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue