~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/os/exec/lp_windows.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
                return
73
73
        }
74
74
        if pathenv := os.Getenv(`PATH`); pathenv != `` {
75
 
                for _, dir := range strings.Split(pathenv, `;`) {
 
75
                for _, dir := range splitList(pathenv) {
76
76
                        if f, err = findExecutable(dir+`\`+file, exts); err == nil {
77
77
                                return
78
78
                        }
80
80
        }
81
81
        return ``, &Error{file, ErrNotFound}
82
82
}
 
83
 
 
84
func splitList(path string) []string {
 
85
        // The same implementation is used in SplitList in path/filepath;
 
86
        // consider changing path/filepath when changing this.
 
87
 
 
88
        if path == "" {
 
89
                return []string{}
 
90
        }
 
91
 
 
92
        // Split path, respecting but preserving quotes.
 
93
        list := []string{}
 
94
        start := 0
 
95
        quo := false
 
96
        for i := 0; i < len(path); i++ {
 
97
                switch c := path[i]; {
 
98
                case c == '"':
 
99
                        quo = !quo
 
100
                case c == os.PathListSeparator && !quo:
 
101
                        list = append(list, path[start:i])
 
102
                        start = i + 1
 
103
                }
 
104
        }
 
105
        list = append(list, path[start:])
 
106
 
 
107
        // Remove quotes.
 
108
        for i, s := range list {
 
109
                if strings.Contains(s, `"`) {
 
110
                        list[i] = strings.Replace(s, `"`, ``, -1)
 
111
                }
 
112
        }
 
113
 
 
114
        return list
 
115
}