title: Redirected output hangs when using tee
body: <p>I'd like to provide an optional logging parameter in a bash script, and would like to use <code>exec</code> to <code>tee</code> a pipe from the beginning.  However, opening the <code>tee</code> process is causing the script to hang, I believe because stdout is not closed:</p>
  
  <pre><code># Output to a log file, if set
  if [[ $OPT_LOG ]]; then
      exec &gt; &gt;(tee -a $OPT_LOG)
  fi
  </code></pre>
  
  <p>I've attempted to close with:</p>
  
  <pre><code>exec &gt;&amp;-
  </code></pre>
  
  <p>But it still hangs - is there another way to properly close <code>tee</code> so the script will exit properly at the end of execution?</p>