The filename syntax is one of the few explicitly system dependent parts of TeX-the-program.
In texlive (ie web2c tex) most characters are allowed (especially after the syntax was changed to allow "
quoting names including spaces). Of course the characters are interpreted by TeX's macro expansion before being considered as possible filename characters, so %
and friends need special handling.
This inputs test%it.tex
on my texlive 2010 (using a cygwin bash shell in windows, but I imagine other command lines would be similar)
pdflatex "\begingroup\lccode44=37 \lowercase{\endgroup\input test,it}"
The warning about $
that you mention comes from kpathsea, as described in its manual
3.3.2 Variable expansion ‘$foo’ or ‘${foo}’ in a path element is replaced by (1) the value of an environment variable ‘foo’ (if
defined); (2) the value of ‘foo’ from ‘texmf.cnf’ (if defined); (3)
the empty string. If the character after the ‘$’ is alphanumeric or
‘_’, the variable name consists of all consecutive such characters. If
the character after the ‘$’ is a ‘{’, the variable name consists of
everything up to the next ‘}’ (braces may not be nested around
variable names). Otherwise, Kpathsea gives a warning and ignores the
‘$’ and its following character.
you can test kpathsea's handling with tests sch as
$ FOO=ZENV tex kps
This is TeX, Version 3.1415926 (Web2C 2010)
(./kps.tex (./a b c.tex
a b c found
) (./ZENV.tex
ZENV found
) )
No pages of output.
Transcript written on kps.log.
which shows that you can refer to environment variables from with tex, kps.tex is
\input "a b c.tex"
\catcode`\$=12
\input "$FOO.tex"
\bye
a b c.tex
is
\immediate\write20{a b c found}
and ZENV.tex is
\immediate\write20{ZENV found}
Best Answer
Not really difficult. It is only an appetizer of how it can be done. This one only reads files *.txt. You have to run it with
pdflatex -shell-escape test