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

Don't panic when calling cp -a with a nonexistent file #2960

Merged
merged 2 commits into from
Jan 30, 2022
Merged

Don't panic when calling cp -a with a nonexistent file #2960

merged 2 commits into from
Jan 30, 2022

Conversation

water-ghosts
Copy link
Contributor

Fixes #2959 by propagating errors from preserve_hardlinks() instead of unwrapping them. On Unix platforms, preserve_hardlinks() returns an Error if the file specified by source does not exist. This was previously causing cp -a abc xyz to panic on Unix if there was no file called abc. This problem did not occur on Windows.

This PR also slightly changes the formatting of the original error to match GNU's output.

Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! Thanks!

@sylvestre sylvestre merged commit 81b2a24 into uutils:main Jan 30, 2022
@water-ghosts water-ghosts deleted the fix-cp-a-panic branch January 31, 2022 07:29
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.

cp -a panics when a file doesn't exist
3 participants