title: Write code (with special chars like \ or ") in variable
body: <p>I have a script (<code>init.sh</code>) which create other scripts. So, in <code>init.sh</code> I want to have variables containing the other scripts. I use <code>read -d</code> to do that :</p>
  
  <pre><code>read -d '' script &lt;&lt;"EOF"
  # Some code
  sed -i "/PARALLEL_MAKE = \"-j 16\"/c\PARALLEL_MAKE = \"-j $threads\"" conf/local.conf
  # Some code
  EOF
  echo "${script}" &gt; script.sh
  </code></pre>
  
  <p>As you can see, I've commands with <code>\</code> and <code>"</code>. But, after running <code>init.sh</code>, in <code>script.sh</code> I have the corresponding line :</p>
  
  <pre><code>sed -i "/PARALLEL_MAKE = "-j 16"/cPARALLEL_MAKE = "-j $threads"" conf/local.conf
  </code></pre>
  
  <p>The <code>\</code> aren't there.</p>
  
  <p>I could try to escape special chars, unsing a lot of <code>\</code>. But my snippets of code are pretty big, and are used in other circumstances (with a simple copy-paste), so I'd like not to do that.</p>
  
  <p>I could also put them in other files, but I can't. I want to do as described -- if possible.</p>