title: Command substitution with variables gives command not found?
body: <p>I'm having a BASH script:</p>
  
  <pre><code>#!/usr/bin/env bash
  
  PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")" &amp;&amp; pwd)
  
  YAML=$(envsubst &lt; ${PATH}/test.yml)
  
  echo "${YAML}"
  </code></pre>
  
  <p>It results:</p>
  
  <pre><code>./test.sh: line 5: envsubst: command not found
  </code></pre>
  
  <p>I see that having a variable inside command substitution causes such error.
  If I'm not using any:</p>
  
  <pre><code>YAML=$(envsubst &lt; ./test.yml)
  </code></pre>
  
  <p>Then I'm having an expected successful script execution.</p>
  
  <p>I've tried different syntax using quotes all over the place, but nothing helped.</p>
  
  <p><strong>How do I successfully use variable inside command substitution?</strong></p>
  
  <p>Bash version:</p>
  
  <pre><code>GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu)
  </code></pre>
  
  <p><strong>UPDATE</strong>: A duplicate question. Found an answer here:
  <a href="https://stackoverflow.com/a/5642584/5935309">https://stackoverflow.com/a/5642584/5935309</a></p>