Advertisement

[ Linux ] How does the tilde/ work?

Started by October 27, 2010 05:07 PM
12 comments, last by Sneftel 14 years, 1 month ago
SimonForsman, thanks, I will check that out too.


Great help from you guys. I didn't expect to get so quick replies on what looks like a relatively quiet forum board.
Quote: Original post by reptor
Kambiz, I try to make the application very robust to these sort of things.
What you see as "robustness" your end user may see as "intransigence". Customizing HOME is how the user indicates where programs should consider the home directory to be. That's why the end user would change HOME.

Don't try to make your program smarter than the user. You will fail.
Advertisement
Really the thing I am trying to do here is to try to keep the application running even when the home directory setting may be messed up somehow.

Maybe I will do it like this:

1) Check if the user gave the application a "profile directory" setting. If there is none or if it doesn't work then

2) try to use the directory stored in the HOME env. var. If it doesn't work then

3) try to get the real home directory of the user by other means.


Certainly the intention is not to try to make the application smarter than the user. The intention is to find a usable directory.


4) In fact the final step is to not have a profile directory at all - there is no reason why the application would need to write anything to a disk. It is a convenience certainly but it is not technically required to use the application.
That mostly makes sense. But consider ease of troubleshooting for the user, and what situations may crop up.

If the user has specified a profile directory, and that profile directory doesn't work, the user probably would want to know about that. In contrast, if the user hasn't specified a profile directory, odds are he doesn't care.

Likewise, if the user has changed HOME, he probably wants to use that instead of the system-reported HOME directory. He'll want to know if it suddenly becomes inaccessible, rather than the system silently failing over to the "real" home directory.

So I would suggest this:

1) Check if the user gave the application a "profile directory" setting. If there is one and it is not accessible, display a warning and go on to 2.

2) Check if the directory stored in the HOME env. var. is different than the one from passwd. If it is, but the directory is not accessible, display a warning and go on to 3.

3) Try to get the real home directory of the user by other means. If it is not accessible, display a warning and go on to 4.

4) No profile directory.

This topic is closed to new replies.

Advertisement