mirror of
https://github.com/golang/go
synced 2024-11-20 09:54:45 -07:00
b4109f801a
On Windows, directory names in PATH can be fully or partially quoted in double quotes ('"'), but the path names as used by most APIs must be unquoted. In addition, quoted names can contain the semicolon (';') character, which is otherwise used as ListSeparator. This CL changes SplitList in path/filepath and LookPath in os/exec to only treat unquoted semicolons as separators, and to unquote the separated elements. (In addition, fix harmless test bug I introduced for LookPath on Unix.) Related discussion thread: https://groups.google.com/d/msg/golang-nuts/PXCr10DsRb4/sawZBM7scYgJ R=rsc, minux.ma, mccoyst, alex.brainman, iant CC=golang-dev https://golang.org/cl/7181047
31 lines
780 B
Go
31 lines
780 B
Go
// Copyright 2010 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package filepath
|
|
|
|
import "strings"
|
|
|
|
// IsAbs returns true if the path is absolute.
|
|
func IsAbs(path string) bool {
|
|
return strings.HasPrefix(path, "/") || strings.HasPrefix(path, "#")
|
|
}
|
|
|
|
// volumeNameLen returns length of the leading volume name on Windows.
|
|
// It returns 0 elsewhere.
|
|
func volumeNameLen(path string) int {
|
|
return 0
|
|
}
|
|
|
|
// HasPrefix exists for historical compatibility and should not be used.
|
|
func HasPrefix(p, prefix string) bool {
|
|
return strings.HasPrefix(p, prefix)
|
|
}
|
|
|
|
func splitList(path string) []string {
|
|
if path == "" {
|
|
return []string{}
|
|
}
|
|
return strings.Split(path, string(ListSeparator))
|
|
}
|