# [texhax] TeX/UNIX

Karl Berry karl at freefriends.org
Thu Nov 2 03:46:07 CET 2006

(Sorry for the delayed reply.)

This is TeX, Version 3.141592 (Web2C 7.5.4)

I think this explains the difference in $behavior. Expanding$ within
filenames was added just last year, in web2c 7.5.5, for example TeX Live
2005.  For earlier versions, you just have to use some extra-TeX
mechanism to expand the variable.

\$ tex '\relax\input  ~/junk/bookdef  \end'
-----
This is TeX, Version 3.141592 (Web2C 7.5.4)
(/usr/pubsw/lib/texmf/tex/latex/tools/.tex File ignored) [1]
Output written on .dvi (1 page, 224 bytes).
Transcript written on .log.
-----
In this case, it produced a file called ".dvi" (no name, only the
extension). This dvi file contained exactly one line of text:
/junk/bookdef

This is actually the expected behavior (I get the same).
Explanation: the
\input  ~/junk/bookdef
is seen by the TeX parser first.  And ~ is a macro in plain TeX, whose
expansion starts with the primitive \penalty.  As far as TeX is
concerned, it's as if the input was:

\input \penalty...

And there are no characters in the input filename.  So TeX appends the
.tex to the null string.  So TeX looks for a file named ".tex", and
finds it (hence the "File ignored", it's a \message inside that file).
No output is produced from that.

Then, TeX continues processing.  The \penalty is discarded, since it's
at the beginning of a line.  That leaves what looks like normal text:
/junk/bookdef, which TeX dutifully typesets.

I assume there was a page number "1" at the bottom, too.

Perhaps this is a good place to quote the TeXbook:
Computers are good at following instructions, but not at reading your mind.

:)

All the best,
Karl