My question is originally the same as use jobname to "pass parameters"?
But that particular question doesn't seem to have a complete answer. (I'm sure that in the minds of experts who deeply know the issue, it is solved.)
Looking at a few other related threads,
How can I check if the filename of a LaTeX document contains a string?
\jobname, character codes and \detokenize
I've been able to largely solve my original question using \IfSubStringInString but not using \ifdefstring. See the example code below.
% run this with pdflatex -jobname=hello thissourcecode.tex
\documentclass{article}
\usepackage{etoolbox}
\usepackage{substr}
\begin{document}
jobname is: ``\jobname''.
% The following gives "true"
\IfSubStringInString{\detokenize{hello}}{\jobname}{substr true}{substr false}
% The following gives "false"
\ifdefstring{\detokenize{hello}}{\jobname}{etoolbox true}{etoolbox false}
\end{document}
The solution with \IfSubStringInString isn't bad at all, except that the package doesn't seem to include a command for exact match. I'd also love to get \ifdefstring to work with \jobname.

\ExpandArgsbit? Quick search on Google didn't show an answer that can be understood by a non-expert like me. Anyway, do you mean that this is the future way to compare strings, to always precede the comparison with\ExpandArgs? Will you or somebody publish a package that includes this string comparison? Also, why can't a macro like this automatically detokenize its arguments? so that\ifstrequal{\jobname}{hello}{ . . .}{ . . .}always works? – Ryo Feb 01 '23 at 18:19etoolboxwas born as a companion package tobiblatexand its functions are tailored for those needs. It's not possible to forecast whatever functions user will need in the future, but LaTeX can be extended, as my answer shows. About\ExpandArgs, readtexdoc usrguide. – egreg Feb 01 '23 at 18:23\usepackageto use the simple macro such as\ifstrequalwithout writing extra code. That's the "future" I'm seeing. – Ryo Feb 02 '23 at 03:16