summaryrefslogtreecommitdiff
path: root/src/pkg/os/getwd.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/os/getwd.go')
-rw-r--r--src/pkg/os/getwd.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pkg/os/getwd.go b/src/pkg/os/getwd.go
index 0235c5d77..8c5ff7fca 100644
--- a/src/pkg/os/getwd.go
+++ b/src/pkg/os/getwd.go
@@ -14,6 +14,10 @@ var getwdCache struct {
dir string
}
+// useSyscallwd determines whether to use the return value of
+// syscall.Getwd based on its error.
+var useSyscallwd = func(error) bool { return true }
+
// Getwd returns a rooted path name corresponding to the
// current directory. If the current directory can be
// reached via multiple paths (due to symbolic links),
@@ -22,7 +26,9 @@ func Getwd() (pwd string, err error) {
// If the operating system provides a Getwd call, use it.
if syscall.ImplementsGetwd {
s, e := syscall.Getwd()
- return s, NewSyscallError("getwd", e)
+ if useSyscallwd(e) {
+ return s, NewSyscallError("getwd", e)
+ }
}
// Otherwise, we're trying to find our way back to ".".