title: How does "FOO= myprogram" in bash make "if(getent("FOO"))" return true in C?
body: <p>I recently ran into a C program that makes use of an environmental variable as a flag to change the behavior of a certain part of the program:</p>
  
  <pre><code>if (getenv("FOO")) do_this_if_foo();
  </code></pre>
  
  <p>You'd then request  the program by prepending the environment variable, <strong>but without actually setting it to anything</strong>:</p>
  
  <p><code>FOO= mycommand myargs</code></p>
  
  <p>Note that the intention of this was to trigger the flag - if you didn't want the added operation, you just wouldn't include the <code>FOO=</code>. However, I've never seen an environment variable set like this before. Every example I can find of prepended variables sets a value, <code>FOO=bar mycommand myargs</code>, rather than leaving it empty like that. </p>
  
  <p>What exactly is happening here, that allows this flag to work without being set? And are there potential issues with implementing environmental variables like this? </p>