title: Replace/substitute adversarial substring variables in shell script
body: <p>I have three unescaped adversarial shell variables.</p>
  
  <pre><code>$mystring
  $old
  $new
  </code></pre>
  
  <p>Remember, all three strings are adversarial. They will contain special characters. They will contain everything possible to mess up the replace. If there is a loophole in your replace, the strings will exploit it.</p>
  
  <p>What is the simplest function to replace $old with $new in $mystring?
  (I couldn't find any solution in stack overflow for a generic substitution that will work in all cases).</p>