title: How to stay in the directory after subshell completion?
body: <p>I'm trying to do this (just an example, not a real life situation):</p>
  
  <pre><code>$ mkdir test; ( cd test; echo "foo" &gt; test.txt ); cat test.txt
  cat: test.txt: No such file or directory
  </code></pre>
  
  <p>However, it fails, since <code>cd test</code> directory change is reverted after subshell is finished. What is a workaround? I can't use script <code>.sh</code> files, everything should be in one command line.</p>