• Brad Fitzpatrick's avatar
    os/exec: fix Command with relative paths · e6d8bfe2
    Brad Fitzpatrick authored
    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
    e6d8bfe2
exec_test.go 17.7 KB