title: knitr with bash: change working directory
body: <p>I am using knitr for making a markdown report for some bash commands. However, my operations include changing a directory and creating a file there, so it would be ideal if I could use <code>cd</code> in my .Rmd file:</p>
  
  <pre><code>make a directory
  ```{r mkdir, engine='bash'}
  mkdir mytest
  ```
  cd into directory
  ```{r cd, engine='bash'}
  cd mytest
  ```
  create file
  ```{r create, engine='bash'}
  touch myfile
  ```
  check contents
  ```{r ls, engine='bash'}
  ls
  ```
  </code></pre>
  
  <p>However, the file <code>myfile</code> is created in the directory from which I compile the document with <code>knit</code> and not in <code>mytest</code>. I guess a new bash shell is started for each code chunk.</p>
  
  <p>I have seen discussions about setting <code>cwd</code> in R    (<a href="https://github.com/yihui/knitr/issues/277" rel="noreferrer">https://github.com/yihui/knitr/issues/277</a>) but not for bash.</p>
  
  <p>Is there a way of maybe setting a working directory for a code chunk?</p>