title: Shell variable expansion - indirection while calling a utility with env
body: <p>I was trying to figure out env, ( i.e. calling a util with a new environment). </p>
  
  <p>Just as an example my environment variable <strong>KDEDIRS = /usr</strong> in my current environment and lets say I type:</p>
  
  <pre><code>env -i KDEDIRS=/home/newkdedir env
  </code></pre>
  
  <p>This outputs <strong>KDEDIRS=/home/newkdedir</strong> as expected. <em>(i.e calling second env with the new environment)</em></p>
  
  <p>Now i wanna call say utility <strong>echo</strong> same way </p>
  
  <pre><code>env -i KDEDIRS=/home/new_kdedir echo ${KDEDIRS}
  </code></pre>
  
  <p>This is obviously not gonna work bec. shell expands KDEDIRS before it gets to echo. So the output is <strong>/usr</strong> <em>(i.e. value in the current environment)</em></p>
  
  <p>Then i try indirection and type in</p>
  
  <pre><code>env -i KDEDIRS=/home/newkdedir echo ${!KDEDIRS} 
  </code></pre>
  
  <p>This outputs nothing.</p>
  
  <p>I might be a little bit confused about this but how can i make the shell expand that <strong>KDEDIRS</strong> variable according to the newly created environment for <strong>echo</strong>?</p>