]> Cypherpunks repositories - gostls13.git/commit
os/exec: fix Command with relative paths
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 3 Feb 2014 21:32:13 +0000 (16:32 -0500)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 3 Feb 2014 21:32:13 +0000 (16:32 -0500)
commite6d8bfe218a5f387d7aceddcaee5067a59181838
tree965fc1516ab382fb6d92c90bb8161d6c78df0f04
parent4723308ff5ab437d2b0892e7cdac86d490495a9b
os/exec: fix Command with relative paths

Command was (and is) documented like:
"If name contains no path separators, Command uses LookPath to
resolve the path to a complete name if possible. Otherwise it
uses name directly."

But that wasn't true. It always did LookPath, and then
set a sticky error that the user couldn't unset.
And then if cmd.Dir was changed, Start would still fail
due to the earlier sticky error being set.

This keeps LookPath in the same place as before (so no user
visible changes in cmd.Path after Command), but only does
it when the documentation says it will happen.

Also, clarify the docs about a relative Dir path.

No change in any existing behavior, except using Command
is now possible with relative paths. Previously it only
worked if you built the *Cmd by hand.

Fixes #7228

LGTM=iant
R=iant
CC=adg, golang-codereviews
https://golang.org/cl/59580044
src/pkg/os/exec/exec.go
src/pkg/os/exec/exec_test.go