fs icon indicating copy to clipboard operation
fs copied to clipboard

fix home function to actually query OS for users home directory

Open retrogradeorbit opened this issue 10 years ago • 2 comments
trafficstars

This resolves issue #12. I haven't tested it on windows, but on windows it will return nil, which is not ideal, but it never actually worked properly anyway, so it might be better.

$ lein midje
All checks (108) succeeded.
me.raynes.fs> (home "crispin")
#object[java.io.File 0x15eda628 "/home/crispin"]
me.raynes.fs> (home "www-data")
#object[java.io.File 0x620327b6 "/var/www"]
me.raynes.fs> (home "root")
#object[java.io.File 0x7358d81 "/root"]
me.raynes.fs> (home "missing-user")
nil
me.raynes.fs> (home "root;echo wat")
nil

retrogradeorbit avatar Aug 08 '15 06:08 retrogradeorbit

Any particular reason this would be better?

Raynes avatar Jan 14 '16 05:01 Raynes

It's better because the existing implementation returns the wrong directory for any non standard user, or any system with users laid out in multiple directory hierarchies. This patch returns the correct home directory for those users. For instance, running as a standard user (who has their home directory under /home/user) ask for the home directory of www-data; say (home "www-data") and the existing implementation returns "/home/www-data" which on my system is completely wrong. www-data's home directory is "/var/www". ask for home dir of "root" and you get "/home/root" not "/root". This patch returns the correct home directory for every user by querying the operating system.

Your comment here aludes to this problem:

https://github.com/Raynes/fs/blob/master/src/me/raynes/fs.clj#L27

retrogradeorbit avatar Nov 17 '16 13:11 retrogradeorbit