# Does tex know its own command line arguments?

Is it possible to test within the document what commandline arguments were passed to tex? The particular case that prompts this is the question Tabs in output file written by xelatex and pdflatex are different where it would be useful to know if the `-8bit` argument has been passed to tex and issue a warning if not. That is, if `pgfplots` could contain the code:

``````\ifxetex
\ifarg{8bit}
\else
\pkgwarning{You're using xe(la)tex without the -8bit argument.  Some external files might go wrong.  If things don't work as you expect, try using the -8bit argument.}
\fi
\fi
``````

then it might make it easier to spot when the situation of the linked question occurs.

(A year after asking the above question, it happened to me again and it took me some time to realise what the problem was and find the solution, even though it had been me who found it last time!)

-

I'm afraid the answer is "not directly".

One can define such a test:

``````\input catchfile.sty
\newif\ifeightbit
\begingroup
\immediate\openout15=tab.tst
\catcode`\^^I=12
\immediate\write15{^^I}
\immediate\closeout15
\CatchFileDef\atab{tab.tst}{\catcode`\^=12 \catcode`I=12 }
\edef\btab{\string^\string^\string I }
\ifx\atab\btab
\global\eightbitfalse
\else
\global\eightbittrue
\fi
\endgroup
\show\ifeightbit
``````

With `xetex test` (`test.tex` is the file name) we'll get `\iffalse` while with `xetex -8bit test` we'll get `\iftrue`.

It seems to be impossible to do this without writing a file, because `\scantokens` avoids the "translation" via the `xchr` tables. So while we can catch the three distinct characters when reading back the file, if written without the `-8bit` option, we can't do it with `\scantokens`.

-
I'm guessing from this that the answer to the general question is "No". –  Loop Space Apr 17 '12 at 20:20
You're guessing right. :) –  egreg Apr 17 '12 at 20:21
Fancy adding that to your answer? It was the actual question, after all! –  Loop Space Apr 17 '12 at 20:25