Commit aac872e1 authored by Alex Brainman's avatar Alex Brainman

os/exec: use filepath.Base in Command

filepath.Base covers all scenarios
(for example paths like d:hello.txt)
on windows

LGTM=iant, bradfitz
R=golang-codereviews, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/59740050
parent 546081fd
......@@ -125,7 +125,7 @@ var pkgDeps = map[string][]string{
"os": {"L1", "os", "syscall", "time"},
"path/filepath": {"L2", "os", "syscall"},
"io/ioutil": {"L2", "os", "path/filepath", "time"},
"os/exec": {"L2", "os", "syscall"},
"os/exec": {"L2", "os", "path/filepath", "syscall"},
"os/signal": {"L2", "os", "syscall"},
// OS enables basic operating system functionality,
......
......@@ -12,6 +12,7 @@ import (
"errors"
"io"
"os"
"path/filepath"
"strconv"
"sync"
"syscall"
......@@ -111,7 +112,7 @@ func Command(name string, arg ...string) *Cmd {
Path: name,
Args: append([]string{name}, arg...),
}
if !containsPathSeparator(name) {
if filepath.Base(name) == name {
if lp, err := LookPath(name); err != nil {
cmd.lookPathErr = err
} else {
......@@ -121,15 +122,6 @@ func Command(name string, arg ...string) *Cmd {
return cmd
}
func containsPathSeparator(s string) bool {
for i := 0; i < len(s); i++ {
if os.IsPathSeparator(s[i]) {
return true
}
}
return false
}
// interfaceEqual protects against panics from doing equality tests on
// two interfaces with non-comparable underlying types.
func interfaceEqual(a, b interface{}) bool {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment