Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syscall: make Getwd check $PWD on OS X #8400

Closed
rsc opened this issue Jul 21, 2014 · 6 comments
Closed

syscall: make Getwd check $PWD on OS X #8400

rsc opened this issue Jul 21, 2014 · 6 comments
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Jul 21, 2014

On OS X, if you cd /tmp and call os.Getwd (which calls syscall.Getwd) it returns
"/private/tmp".

In Go 1.2 and earlier it returned "/tmp", because it used the "check
$PWD, and then walk .. repeatedly" algorithm. CL 12349044 changed it to use
getattrlist, so in Go 1.3 it returns "/private/tmp" (/tmp is a symlink to
/private/tmp).

The C library routine getwd returns "/tmp". I know this because liblink in C
sees "/tmp" and liblink in Go sees "/private/tmp".

I think we should probably add the $PWD check to OS X's syscall.Getwd (or else move it
up above the ImplementsGetwd check in package os's Getwd, but changing OS X alone is the
more conservative change).

CL 118970043 does this. We just have to decide if that's what we want to do.
@ianlancetaylor
Copy link
Contributor

Comment 1:

I vote for moving the PWD check to the start of os.Getwd.  That pretty much always the
right thing to do in practice.  It's less conservative but I can't think of anything
likely to break.

Labels changed: added repo-main.

@rsc
Copy link
Contributor Author

rsc commented Aug 6, 2014

Comment 2:

This may be worth 1.3.1. Not sure.

Labels changed: added release-go1.3.1, removed release-go1.4.

@gopherbot
Copy link

Comment 3:

CL https://golang.org/cl/118970043 mentions this issue.

@rsc
Copy link
Contributor Author

rsc commented Aug 7, 2014

Comment 4:

This issue was closed by revision 6cee4d3.

Status changed to Fixed.

@ianlancetaylor
Copy link
Contributor

Comment 5:

That CL broke Windows; see https://golang.org/cl/119600043/ for a (ugly) fix.

@rsc
Copy link
Contributor Author

rsc commented Aug 11, 2014

Comment 6:

No one is reporting this problem except me.
Delaying to 1.4.

Labels changed: added release-go1.4, removed release-go1.3.1.

@rsc rsc added fixed labels Aug 11, 2014
@rsc rsc self-assigned this Aug 11, 2014
@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
This makes os.Getwd mimic C getwd on OS X,
and possibly other systems. The change on OS X
was a regression from 1.2 to 1.3.

Fixes golang#8400.

LGTM=bradfitz
R=iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/118970043
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
This makes os.Getwd mimic C getwd on OS X,
and possibly other systems. The change on OS X
was a regression from 1.2 to 1.3.

Fixes golang#8400.

LGTM=bradfitz
R=iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/118970043
@rsc rsc removed their assignment Jun 23, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants