title: Is it possible to combine HERE document and redirection to write to file without spawning process in Bash?
body: <p>Is it possible to combine HERE document and redirection to write to file without spawning process in Bash?</p>
  <p>The standard solution involve <code>cat</code> command, it is a separate process, not a built-in command:</p>
  <pre class="lang-sh prettyprint-override"><code>cat &gt;my.cfg &lt;&lt;EOF
  user = 'me'
  dir = &quot;$PWD&quot;
  EOF
  </code></pre>
  <p><code>echo</code> can be used, but quoting and repetition are involved (HERE document simplifies quoting!):</p>
  <pre class="lang-sh prettyprint-override"><code>echo &quot;user = 'me'&quot; &gt;&gt;my.cfg
  echo &quot;dir = &quot;'&quot;'&quot;$PWD&quot;'&quot;' &gt;&gt;my.cfg
  </code></pre>
  <p>There is another echo style with multiline quotation and still quoting complicates code a bit:</p>
  <pre class="lang-sh prettyprint-override"><code>echo &quot;user = 'me'
  dir = \&quot;$PWD\&quot;&quot; &gt;my.cfg
  </code></pre>
  <p>I am particularly looking for a solution that doesn't rely on <strong>fork()</strong> using some Bash tricks + HERE document to avoid quoting issues (except of quoting <code>$</code> sign)...</p>