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

realpath: add -L and -P command-line arguments #2530

Closed

Conversation

jfinkels
Copy link
Collaborator

Partially resolves issue #2253.

This pull request adds the -L (logical) and -P (physical) command-line arguments to realpath. The -L option makes the program resolve ".." components before symbolic links. The -P option makes the program resolve symbolic links as they are encountered. This also changes the default behavior of realpath from the -L behavior to the -P behavior. This matches the behavior of GNU realpath. I don't fully understand all the things that -L is supposed to do, but this is a start, and seems to match the basic tests in the GNU coreutils test suite.

@jfinkels jfinkels force-pushed the realpath-logical-physical-args branch from b4793ad to 14977c8 Compare July 28, 2021 23:39
src/uucore/src/lib/features/fs.rs Outdated Show resolved Hide resolved
src/uu/realpath/src/realpath.rs Outdated Show resolved Hide resolved
jfinkels added 3 commits July 29, 2021 22:44
Refactor the `uucore::fs::canonicalize()` function into three helper
functions. The first gets the absolute name of the path, the second
breaks the path into its components, and the third resolves all symbolic
links in the path.
Add the `logical` argument to the `uucore::fs::canonicalize()`
function. This argument controls whether symbolic links are resolved
before or after ".." components are resolved.
Add the `-L` (logical) and `-P` (physical) command-line arguments to
`realpath`. The `-L` option makes the program resolve ".." components
before symbolic links. The `-P` option makes the program resolve
symbolic links as they are encountered.

This also changes the default behavior of `realpath` from the `-L`
behavior to the `-P` behavior. This matches the behavior of GNU
`realpath`.
@jfinkels jfinkels force-pushed the realpath-logical-physical-args branch from 14977c8 to 65037a4 Compare July 30, 2021 02:46
@jfinkels
Copy link
Collaborator Author

I have made the changes suggested by @miDeb and rebased this branch on master.

@jfinkels
Copy link
Collaborator Author

Looks like I've broken the Windows and Mac builds. I only have Linux, so if someone sees an obvious fix that would be very helpful to me.

@jfinkels
Copy link
Collaborator Author

I think maybe I'll post a new pull request containing just the changes to uucore::fs::canonicalize() in order to make it a little easier to review and fix issues with the various operating systems.

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.

2 participants