kpathsea: Tilde expansion
5.3.3 Tilde expansion
---------------------
A leading '~' in a path element is replaced by the value of the
environment variable 'HOME', or '.' if 'HOME' is not set. On Windows,
the environment variable 'USERPROFILE' is checked instead of 'HOME'.
A leading '~USER' in a path element is replaced by USER's home
directory from the system 'passwd' database.
For example,
setenv TEXINPUTS ~/mymacros:
will prepend a directory 'mymacros' in your home directory to the
default path.
As a special case, if a home directory ends in '/', the trailing
slash is dropped, to avoid inadvertently creating a '//' construct in
the path. For example, if the home directory of the user 'root' is '/',
the path element '~root/mymacros' expands to just '/mymacros', not
'//mymacros'.
Tilde expansion is implemented in the source file 'kpathsea/tilde.c'.