[Tex/LaTex] How to latex and pdflatex be both symbolic links to same executable (pdftex) and not behave the same

format-filestex-core

When I run

$ latex my_doc.tex

and

$ pdflatex my_doc.tex

it works, and when I run

$ pdftex my_doc.tex

it doesn't work.

The thing is I noticed that both LaTeX and pdflatex commands are symbolic links to the same pdftex executable. That is,

$ which latex pdflatex pdftex

yields

/usr/bin/latex
/usr/bin/pdflatex
/usr/bin/pdftex

and

$ ls -l /usr/bin/latex /usr/bin/pdflatex /usr/bin/pdftex

yields

/usr/bin/latex -> pdftex
/usr/bin/pdflatex -> pdftex
/usr/bin/pdftex

So how is it possible that commands being symbolic links to a same executable do not behave in the same way ?

Thanks.

I have Ubuntu 12.10 with TeXLive-full 2012.20120611-4 installed.

Best Answer

Programs get passed argv[0] ie the name by which they are called as well as any explicit following arguments and they can, and do test this and act accordingly. Basically if you make a symbolic link or copy of a web2c tex executable then it acts like tex &zzz where zzz is the name of the copy or link.

Related Question