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

`path()` silently ignores zero-length input #54

mllg opened this Issue Jan 25, 2018 · 1 comment


None yet
2 participants
Copy link

mllg commented Jan 25, 2018

This is probably just a matter of taste, but path() behaves differently compared to file.path() for 0-length input:

file.path("a", character(0)) # -> character(0)
fs::path("a", character(0)) # -> "a"

If the second part is the result of some kind of filtering (is_dir(), file.mtime(), ...), you might end up accidentally deleting the base directory instead of only those candidates for which the filter criterion holds (which is exactly how I stumbled about this).

@jimhester jimhester closed this in e4900db Jan 25, 2018


This comment has been minimized.

Copy link

jimhester commented Jan 25, 2018

I agree with you, I actually ran into this when I was rewriting dir_copy() as well. Should now work similarly to file.path() for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment