Printing Latex source with a2ps

a2pslatexprinting

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.

Best Answer

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

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

Instead of

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.

Related Question