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

Avoid fs::canonicalize #539

Merged
merged 1 commit into from
Nov 19, 2019
Merged

Avoid fs::canonicalize #539

merged 1 commit into from
Nov 19, 2019

Conversation

casey
Copy link
Owner

@casey casey commented Nov 19, 2019

Previously, we used fs::canonicalize to ensure paths used in search
were absolute. This lead to bad behavior when the justfile was symbolic
link to a file in another directory. Additionally, on Windows, this
produced paths in extended length syntax, which, I believe, has
compatibility issues.

This diff replaces uses of fs::canonicalize with a simpler algorithm
that roots path in the invocation directory (which will be a no-op if
said path is already absolute), uses Path::components to remove extra
/ and ., and resolves instances of .. without following symlinks,
i.e. by removing the .., and the component that proceeds it.

Fixes #538.

Previously, we used `fs::canonicalize` to ensure paths used in search
were absolute. This lead to bad behavior when the justfile was symbolic
link to a file in another directory. Additionally, on Windows, this
produced paths in extended length syntax, which, I believe, has
compatibility issues.

This diff replaces uses of `fs::canonicalize`  with a simpler algorithm
that roots path in the invocation directory (which will be a no-op if
said path is already absolute), uses `Path::components` to remove extra
`/` and `.`, and resolves instances of `..` without following symlinks,
i.e. by removing the `..`, and the component that proceeds it.
@casey casey changed the title Root search paths in invocation directory Avoid fs::canonicalize Nov 19, 2019
@casey casey merged commit c4e9857 into master Nov 19, 2019
@casey casey deleted the clean branch November 19, 2019 11:51
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

Successfully merging this pull request may close these issues.

Symlinks and the working directory
1 participant