I compared a few Rust libraries for tilde expansion.
@liw Thanks for writing that! And ugh, #Rust has actual types to avoid the encoding mess, so why are crates using UTF8 instead of Path? This is one of my big complaints about #Python 3 and there is NO reason to replicate it in Rust. https://changelog.complete.org/archives/10063-the-fundamental-problem-in-python-3
@liw Also the next step would be to verify that those that accept a Path work with strings that aren't valid UTF8. Maybe they just convert to UTF8 internally.
@jgoerzen I did that, actually, for the home-dir crate. As part of seeing what I can do help improve the crate.
@liw "The crate MUST report errors, especially for an input that refers to a non-existent user."
hmm, ~foo/bar is a valid name for a file whether user foo exists or not. Not a name I'd choose to use, but it could be a mistake for tilde expansion to consider it an error if foo does not exist.
@joeyh I disagree that it should be silently accepted. If the calling program is OK with accepting it if the user does not exist, they can do that explicitly.
@liw well, I took a look at a real-world use case of this: a git repository with a remote like ~foo/bar, on a removable drive, so it may or may not currently be on a machine with that user
git remains usable in that repository regardless, which is good
git-annex didn't think to catch the tilde expansion exception and was unusable (fixed)
git seems to be somewhat inconsistent about whether it accesses ./~foo/bar when the user DNE. Parts of it seem to handle the edge case in different ways.
@joeyh I agree that user not existing should be handled in an appropriate way. I disagree that the tilde expansion library should just silently handle it.
Lars and friends