kpathsea: Default expansion
5.3.1 Default expansion
-----------------------
If the highest-priority search path (⇒Path sources) contains an
"extra colon" (i.e., leading, trailing, or doubled), Kpathsea inserts at
that point the next-highest-priority search path that is defined. If
that inserted path has an extra colon, the same happens with the
next-highest. (An extra colon in the compile-time default value has
unpredictable results, so installers beware.)
For example, given an environment variable setting
setenv TEXINPUTS /home/karl:
and a 'TEXINPUTS' value from 'texmf.cnf' of
.:$TEXMF//tex
then the final value used for searching will be:
/home/karl:.:$TEXMF//tex
Put another way, default expansion works on "formats" (search paths),
and not directly on environment variables. Example, showing the
trailing ':' ignored in the first case and expanded in the second:
$ env TTFONTS=/tmp: kpsewhich --expand-path '$TTFONTS'
/tmp
$ env TTFONTS=/tmp: kpsewhich --show-path=.ttf
/tmp:.:/home/olaf/texmf/fonts/truetype//:...
Since Kpathsea looks for multiple configuration files, it would be
natural to expect that (for example) an extra colon in './texmf.cnf'
would expand to the path in '$TEXMF/texmf.cnf'. Or, with Dvips'
configuration files, that an extra colon in 'config.$PRINTER' would
expand to the path in 'config.ps'. This doesn't happen. It's not clear
this would be desirable in all cases, and trying to devise a way to
specify the path to which the extra colon should expand seemed truly
baroque.
Technicality: Since it would be useless to insert the default value
in more than one place, Kpathsea changes only one extra ':' and leaves
any others in place (they will eventually be ignored). Kpathsea checks
first for a leading ':', then a trailing ':', then a doubled ':'.
You can trace this by debugging "paths" (⇒Debugging). Default
expansion is implemented in the source file 'kpathsea/kdefault.c'.