# Printing Latex source with a2ps

When I try to print out latex source code with

a2ps somefile.tex


I get error messages from egrep like

egrep: Das Ende des angegebenen Intervalls ist nicht gültig


which translates to "the end of the given interval is invalid." After that texi2dvia4ps tries to compile my tex file and fails. I can print other source code just fine. Any idea what's wrong?

Edit: jofels answer fixes the problem with egrep. a2ps still tries to compile my .tex file instead of pretty printing it as source code. Using

a2ps --delegate=no somefile.tex


stops it (partly) from doing so. Minor commands like \item or \phi are still interpreted instead of printed out as they are in the file.

-

The message (in English "egrep: Invalid range end") comes from a bug in a2ps.

Its /usr/bin/texi2dvi4a2ps shell script calls egrep wrongly:

echo "$command_line_filename" | egrep '^(/|[A-z]:/)' >/dev/null \ || command_line_filename="./$command_line_filename"


it should be

echo "$command_line_filename" | egrep '^(/|[A-Za-z]:/)' >/dev/null \ || command_line_filename="./$command_line_filename"


As the bug is in a shell script, you can fix it easily by just editing the file.

The pattern checks if the filename is absolute (starts with an /, relevant on Unix-like systems) or starts with a drive name (e.g. C:, relevant only for Windows systems). Otherwise, the filename is prepended with ./.

Feel free to report this bug upstream or to the distribution you use.

-
What does it grep? If it is user input that would further limit to ASCII. –  Sukminder May 2 '13 at 11:20
@Sukminder I have extended my answer. The actual pattern is not relevant for Unix-like systems. –  jofel May 2 '13 at 11:30