Compare two macros as strings in LaTeX (e-TeX)

How do I compare two macros that are one-expansion away from being strings?

\def\A{ICT}
\newgetenv[\ICT]{\A}
% \newgetenv from https://tex.stackexchange.com/a/184924

Now I want to check if whatever \ICT evaluates to is simply what \A evaluates to; i.e.: "ICT".

Attempts (one line at a time; others commented):

\ifdefequal{\expandafter\ICT}{\expandafter\A}{\def\ICT{FOO}}{\def\ICT{BAR}}
\ifdefequal{\ICT}{\expandafter\A}{\def\ICT{FOO}}{\def\ICT{BAR}}
\ifdefequal{\expandafter\ICT}{\A}{\def\ICT{FOO}}{\def\ICT{BAR}}

I've also tried the same 3 possibilities with \ifcsequal and \ifdefstring. Also tried giving up on the \A and just using: ICT verbatim.


produces

> \ICT=macro:
->FOO.

unless ICT=ICT when you get

ICT='ICT' ;pdflatex \\def\\ICT{\$ICT}\\input pp024

which produces

> \ICT=macro:
->BAR.
• Actually I was testing if ICT environment variable was defined. When it's not defined, for some reason it gets the verbatim ICT text. I'm using latexmk to build my LaTeX project, within a regular Makefile. Your code did not work in this setup. – A T Jun 19 '17 at 5:25
• @AT The code is pure tex code so will work the same way whether tex is called from the command line or from latexmk or a makefile. the form setting the environment variable on the same line is bash syntax but there is no requirement to set the variable in that way, just set it however you wish. – David Carlisle Jun 19 '17 at 6:35
• Hmm, well does it matter if \newgetenv[; \ifx; is in the prelude (before \begin{document})? – A T Jun 19 '17 at 6:40
• @AT probably not, but you've posted two questions on this now and still not shown a reproducible example of what you are doing or what error you get. – David Carlisle Jun 19 '17 at 6:42
• Using your exact code example, and it doesn't work. pdflatex example0.tex; > \ICT=macro: ->FOO. and running export ICT=foo beforehand still gives same output. – A T Jun 19 '17 at 6:52