Environment variable in if condition is not working

Referencing an environment variable in a conditional. You would think it would be supported, but it is not. See this thread.