title: Is it bad practice to use environment variables in rm -rf statements?
body: <p>I was maintaining some shell scripts that we use for automated builds on our development server, when i moved a variable definition from on script file to another, along with several other lines of code. As a result, this line:</p>
  
  <pre><code>WEB=/home/server/web
  </code></pre>
  
  <p>got moved from that script file into another script file, and was no longer in the environment utilized by the first script file. Thus, later in the file,</p>
  
  <pre><code>rm -rf $WEB/*
  </code></pre>
  
  <p>got evaluated to the Linux user's dreaded command: <code>rm -rf /*</code></p>
  
  <p>My question is, would you consider using environment variables in this way bad practice or considered harmful? Something like the classic</p>
  
  <pre><code>if (foo)
      bar()
      bar2()
  </code></pre>
  
  <p>where the implications of removing the variable declaration are not immediately obvious, and can be surprising down the line? Or should i just be more careful when moving things like this around?</p>