I have a command that (beyond my control) evaluate into a token list, and I want to compare it to a given string, I tried to follow this answer and create a variant on \tl_if_eq:
\ExplSyntaxOn
\NewDocumentCommand{\cmp}{mm}
{
\tl_set:Nn \l_r_tl { #1 }
\cs_generate_variant:Nn \tl_if_eq:nnTF { o }
\tl_if_eq:onTF { \l_r_tl } { #2 } { True } { False }
%% I also tried:
% \tl_if_eq:onTF { #1 } { #2 } { True } { False }
}
\tl_new:N \l_r_tl
% The actual command I am using retrieve values using \sys_get_shell, so I don't have control over it
\NewDocumentCommand{\dummy}{m}{
\tl_set:Nn \l_d_tl { #1 }
\l_d_tl
}
\tl_new:N \l_d_tl
\ExplSyntaxOff
But seems like this doesn't seem to work if my value is passes through "dummy":
\begin{document}
\maketitle
\cmp{test}{test} % True
\cmp{\dummy{test}}{test} % False
\dummy{test} % test
\end{document}
How can I get it to evaluate to "True" even when I pass on a tl from a different command?
Edit: Adding MWE as requested:
\documentclass[12pt,reqno]{article}
\usepackage{expl3}
\ExplSyntaxOn
\NewDocumentCommand{\cmp}{mm}
{
\tl_set:Nn \l_r_tl { #1 }
\cs_generate_variant:Nn \tl_if_eq:nnTF { o }
\tl_if_eq:onTF { \l_r_tl } { #2 } { True } { False }
%% I also tried:
% \tl_if_eq:onTF { #1 } { #2 } { True } { False }
}
\tl_new:N \l_r_tl
% The actual command I am using retrieve values using \sys_get_shell, so I don't have control over it
\NewDocumentCommand{\dummy}{m}{
\tl_set:Nn \l_d_tl { #1 }
\l_d_tl
}
\tl_new:N \l_d_tl
\ExplSyntaxOff
\begin{document}
\cmp{test}{test} % True
\cmp{\dummy{test}}{test} % False
\dummy{test} % test
\end{document}
\documentclass{}and end with\end{document}though please, a Minimal Working Example (MWE) please. It makes copy and pasting easier when the code can be compiled as-is – JamesT May 27 '23 at 15:00dummythen the problem is not solvable. Try to look at the documentation to see if thedummyhas an alternative command that stores the result into some token list, then read from that token list (for which it's impossible to give a more specific answer without you explaining what thedummyis) – user202729 May 27 '23 at 15:07\dummyis a call to\sys_get_shell:nnN, which does store the result in atl, I inlined the call and used that variable and now it works! – Yuval Shmuel May 27 '23 at 15:23\cs_generate_variant:Nn \tl_if_eq:nnTF { o }outside your definition you only need it once not every time – David Carlisle May 28 '23 at 11:27