Is it possible to use a \csdef{}{} on the command line to pass in parameters to pdflatex?
Background:
If the MWE below is saved as "TeX-SE.tex", I can use the following command line to define the value of \MyCommandViaDef
pdflatex "\def\MyCommandViaDef{123} \input{TeX-SE.tex}"
and things work as desired:
When I need to define a more complicated command that contains file names with dashes, using \def is no longer an option.
I realize I can use
pdflatex "\def\MyCommandViaDef{123} \expandafter\def\csname MyCommand Via Csdef\endcsname{xyz} \input{TeX-SE.tex}"
to obtain the desired results
but using a \csdef{}{} such as would be preferrable.
pdflatex "\def\MyCommandViaDef{123} \csdef{MyCommand Via Csdef}{xyz} \input{TeX-SE.tex}"
Code:
\documentclass{article}
\usepackage{etoolbox}
\begin{document}
Value via def: \MyCommandViaDef
\ifcsdef{MyCommand Via Csdef}{%
Value via csdef: \csuse{MyCommand Via Csdef}
}{%
Value via csdef: Not Available
}%
\end{document}




\RequirePackage{etoolbox}first to define csdef, then use --jobname to stop the jobname beingetoolboxetoolboxdefines\csdef(\newrobustcmd*{\csdef}[1]{\expandafter\def\csname#1\endcsname}), so it's not available before loading it. You can define\csdefusing\newcommand{\csdef}[1]{\expandafter\def\csname#1\endcsname}, but that sort of defeats the purpose...\AtBeginDocument{\csdef\....\@namedef. Except the latter requires@of catcode11.