obsidian-export icon indicating copy to clipboard operation
obsidian-export copied to clipboard

handle home directory expansion

Open skewballfox opened this issue 2 years ago • 2 comments

currently if you supply a path with a tilde character, you get a runtime panic. I added a function to simply replace ~ with the home directory. It adds one dependency, though one maintained by the cargo team. This could be done without adding another dependency, though using a deprecated function std::env::home_dir()(which honestly the dependency is just calling and handling the edge cases not handled).

If you want me to change anything, let me know.

skewballfox avatar Dec 30 '23 23:12 skewballfox

Truthfully, I'm quite on the fence about this. Path expansion should be the responsibility of the user's shell in my opinion, and allowing homedir/tilde expansion would open up the door to other similar requests in the future.

zoni avatar Dec 31 '23 00:12 zoni

Truthfully, I'm quite on the fence about this. Path expansion should be the responsibility of the user's shell in my opinion, and allowing homedir/tilde expansion would open up the door to other similar requests in the future.

fair, though the reason I opened the PR was because I ran into an edge case where the ~ character wasn't expanded: the path was in an env variable being used in a bash script, and in this situation, the path wasn't expanded. I suppose it might be better to handle within that shell script, given there are situations this doesn't cover (like ~foo to expand to /home/foo).

If you would rather not merge that's totally fine.

skewballfox avatar Dec 31 '23 00:12 skewballfox