MATCH: Add patterns from phiopt's minmax_replacement
[official-gcc.git] / libgo / go / os / executable_darwin.go
blobdae9f4ee18ecb96aa32712d1375a8dd2cc8fb6d0
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package os
7 import "errors"
9 var executablePath string // set by ../runtime/os_darwin.go
11 var initCwd, initCwdErr = Getwd()
13 func executable() (string, error) {
14 ep := executablePath
15 if len(ep) == 0 {
16 return ep, errors.New("cannot find executable path")
18 if ep[0] != '/' {
19 if initCwdErr != nil {
20 return ep, initCwdErr
22 if len(ep) > 2 && ep[0:2] == "./" {
23 // skip "./"
24 ep = ep[2:]
26 ep = initCwd + "/" + ep
28 return ep, nil