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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
)
11
11
 
12
12
// ErrNotFound is the error resulting if a path search failed to find an executable file.
13
 
var ErrNotFound = os.ErrorString("executable file not found in %PATH%")
 
13
var ErrNotFound = os.NewError("executable file not found in %PATH%")
14
14
 
15
15
func chkStat(file string) os.Error {
16
16
        d, err := os.Stat(file)
38
38
                        return f, nil
39
39
                }
40
40
        }
41
 
        return ``, ErrNotFound
 
41
        return ``, os.ENOENT
42
42
}
43
43
 
44
44
func LookPath(file string) (f string, err os.Error) {
 
45
        x := os.Getenv(`PATHEXT`)
 
46
        if x == `` {
 
47
                x = `.COM;.EXE;.BAT;.CMD`
 
48
        }
45
49
        exts := []string{}
46
 
        if x := os.Getenv(`PATHEXT`); x != `` {
47
 
                exts = strings.Split(strings.ToLower(x), `;`, -1)
48
 
                for i, e := range exts {
49
 
                        if e == `` || e[0] != '.' {
50
 
                                exts[i] = `.` + e
51
 
                        }
52
 
                }
 
50
        for _, e := range strings.Split(strings.ToLower(x), `;`) {
 
51
                if e == "" {
 
52
                        continue
 
53
                }
 
54
                if e[0] != '.' {
 
55
                        e = "." + e
 
56
                }
 
57
                exts = append(exts, e)
53
58
        }
54
 
        if strings.Contains(file, `\`) || strings.Contains(file, `/`) {
 
59
        if strings.IndexAny(file, `:\/`) != -1 {
55
60
                if f, err = findExecutable(file, exts); err == nil {
56
61
                        return
57
62
                }
62
67
                        return
63
68
                }
64
69
        } else {
65
 
                for _, dir := range strings.Split(pathenv, `;`, -1) {
 
70
                for _, dir := range strings.Split(pathenv, `;`) {
66
71
                        if f, err = findExecutable(dir+`\`+file, exts); err == nil {
67
72
                                return
68
73
                        }