title: envsubst: default values for unset variables
body: <p>I've got a json file <code>input.json</code> like the following one:</p>
  
  <pre><code>{
    "variable" : "${ENV_VAR}"
  }
  </code></pre>
  
  <p>of course, I can invoke envsubst from bash like the following:</p>
  
  <pre><code>$ export ENV_VAR=myvalue
  $ envsubst &lt; input.json &gt; output.json
  $ cat output.json
  {
    "variable" : "myvalue"
  }
  </code></pre>
  
  <p>Now, I wish I could set default values for variables in the input.json for the case when <code>ENV_VAR</code> is not set, like in the following example which, as unfortunately can be seen in the example below, doesn't work:</p>
  
  <pre><code>$ cat input.json
  {
    "variable" : "${ENV_VAR:=defaultvalue}"
  }
  $ export ENV_VAR=newvalue
  $ envsubst &lt; input.json &gt; output.json
  $ cat output.json
  {
    "variable" : "${ENV_VAR:=defaultvalue}"
  }
  $ unset ENV_VAR
  $ envsubst &lt; input.json &gt; output.json
  $ cat output.json
  {
    "variable" : "${ENV_VAR:=defaultvalue}"
  }
  </code></pre>
  
  <p>What's curious, if I execute the envsubst like in the following example (without involving an input file), it works</p>
  
  <pre><code>$ export ENV_VAR=myvalue
  $ echo "value is ${ENV_VAR:=defaultvalue}" | envsubst
  value is myvalue
  $ unset ENV_VAR
  $ echo "value is ${ENV_VAR:=defaultvalue}" | envsubst
  value is defaultvalue
  </code></pre>
  
  <p>Where is the problem with the files?</p>