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

normalization should not affect the resolved path #18

Open
agarwal opened this issue Dec 11, 2015 · 1 comment
Open

normalization should not affect the resolved path #18

agarwal opened this issue Dec 11, 2015 · 1 comment

Comments

@agarwal
Copy link
Member

agarwal commented Dec 11, 2015

# let x = Cons (Link(name_exn "foo", Item Dot), Item Dotdot);;
val x : (rel, dir) t = Cons (Link ("foo", Item Dot), Item Dotdot)

# normalize x;;
- : (rel, dir) t = Item Dot

Path x semantically (i.e. resolve and then normalize) points to Dotdot, but normalize returns Dot. The reason is our implementation of normalize does

| Link _, Item Dotdot -> Item Dot

which moves up through the link. This definition agrees with my shell's behavior (where the prompt is configured to show the current working directory):

~/phat-test $ ln -s . a
~/phat-test $ ls -al
lrwx------    1 ashish  staff     1B Dec 11 11:08 a -> .
~/phat-test $ cd a
~/phat-test/a $ cd ..
~/phat-test $

The shell treats a as a regular directory. Doing a cd moves you to it, with PWD showing you one level lower in your directory tree, even though a points to the current directory. This isn't necessarily wrong, but doesn't align with our goal for normalize, which is that normalization shouldn't change a path's semantics. The shell could reasonably have implemented an alternative, that cding to a link takes you to its target, but there is an attempt here at letting users leave the link unresolved. Presumably this is more intuitive in some cases.

Originally reported by @pveber.

@agarwal
Copy link
Member Author

agarwal commented Dec 11, 2015

Decision: a normalized path can also include a Link followed immediately by one or more Dotdots.

pveber added a commit that referenced this issue Dec 12, 2015
I would use normalize in `reify` to avoid dealing with Dot and
Dotdot. In particular I would follow (rel) links by concatenating with
the dirname of the link and its target (correct) then normalize
(incorrect, at least till #18 is not addressed).

This commit removes uses of `normalize` and deals with Dot and Dotdot
cases (which were not difficult at all, in the end).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant