This is a problem that crops up from time to time and annoys me greatly.
Sometimes I need to provide an absolute path, normally in a configuration file, that should refer to the current user's home directory, but where the configuration file does not understand bash's tilde or variable expansion (so ~/foobar, $HOME/foobar, and /home/$USER/foobar are all out).
My ideal solution would be if there were some 'active' symbolic link within /proc or similar that always expands to the current user's home directory. For example, we have /proc/self, which is a symbolic link with a value that depends upon the process accessing it. Does a similar link exist that always refers to the current user's home directory?
This often crops up when writing re-usable configurations that will be shared with others within an organisation, or with myself across computers (where my username may be different between computers). It can also crop up as an obstacle in making configuration files relocatable. For example, ideally creating a tarball of my $HOME and extracting it to another user's $HOME would immediately setup the other user with an environment identical to my own, but if all my symlinks and/or configuration files are hardcoded with /home/cdfh/..., then clearly this won't work.
In all cases, there have always been workarounds, but having the ability to refer to $HOME with /proc/home would be phenomenally useful.
So, after years of unsatisfactory workarounds, I'm asking: does anyone else suffer from this problem? What workarounds have you found? Are there any solutions?
Edits:
My platform is Linux, although I would ask this question on behalf of any/all Unix-derived systems.
Regarding the "active" approach, these questions are relevant, and the outcome is that I would use scriptfs to create a filesystem where reading a file no longer reads the data of the file, but rather executes a process whose standard output substitutes as the file data. The process would thus output data that acts as a symbolic link to the reading user's home directory. I sadly haven't had a chance to implement this yet.
Rephrasing the question using what I now understand to be the proper terminology, I want to create a variable symlink that produces a link on the basis of the HOME environment variable. Unfortunately, variable symlinks are not natively supported by Linux, but can be implementing using FUSE-based approaches, such as above. Curiously, they are supported in various BSDs, and some are advocating bringing support to Linux.