[tex-live] Access to Windows environment variables from \input

Zdenek Wagner zdenek.wagner at gmail.com
Mon Oct 6 22:02:05 CEST 2014

2014-10-06 21:15 GMT+02:00 Philip Taylor <P.Taylor at rhul.ac.uk>:
> A TeX source needs to reference images from a location that is
> host-dependent, and I had hoped to accomplish this by \inputting a
> configuration file partially specified by a Windows environment
> variable.  In essence :
> D:\>set test=d:\
> D:\>tex
> This is TeX, Version 3.1415926 (TeX Live 2013/W32TeX)
> **\catcode `\% = \catcode `\a \input %test%/config.tex
> *\end
> However, not only does TeX (or XeTeX, or PdfTeX) not open the desired
> file, the diagnostic is even more confusing :
> (d:/TeX/Live/2013/texmf-dist/tex/latex/tools/.tex File ignored)
> No pages of output.
> Transcript written on texput.log.
> Cam anyone explain (a) why the environment variable is not deferenced
> when \input passes its parameter to the appropriate system internal, and
> (b) why TeX /does/ open (or perhaps only try to open)
> d:/TeX/Live/2013/texmf-dist/tex/latex/tools/.tex ?
Environment variables are expanded by cmd.exe, not by I/O libraries.
For these libraries % is just a character. You would have to call a
system library for retrieving the environment variables. And the names
of the environment variables are case sensitive and must be all
uppercase. You can use set test=something and both echo %test% and
echo %TEST% (and even echo %TesT%) will work because the conversion to
uppercase will be done automatically by cmd.exe but it does not happen
when called directly from your program. TEST will have the expected
value while the value of test will be an empty string with no error
message. TeX does not allow you to access environment variables but it
might be possible by luatex (I do not know luatex, I just guess).

> Philip Taylor

Zdeněk Wagner

More information about the tex-live mailing list