title: Safer alternative to MATLAB's `system` command
body: <p>I have been using MATLAB's <code>system</code> command to get the result of some linux commands, like in the following simple example:</p>
  
  <pre><code>[junk, result] = system('find ~/ -type f')
  </code></pre>
  
  <p>This works as expected, <em>unless</em> the user types into MATLAB's command window at the same time. Which during a long <code>find</code> command is not uncommon. If this happens then the user's input seems to get mixed up with the result of the <code>find</code> command (and then things break).</p>
  
  <p>As an example, instead of:</p>
  
  <pre><code>/path/to/file/one
  /path/to/file/two
  /path/to/file/three
  /path/to/file/four
  </code></pre>
  
  <p>I might get:</p>
  
  <pre><code>J/path/to/file/one
  u/path/to/file/two
  n/path/to/file/three
  k/path/to/file/four
  </code></pre>
  
  <p>In order to demonstrate this easily, we can run something like:</p>
  
  <pre><code>[junk, result] = system('cat')
  </code></pre>
  
  <p>Type something into the command window and press CTRL+D to close the stream. The <code>result</code> variable will be whatever you typed in to the command window.</p>
  
  <p>Is there a safer way for me to call system commands from MATLAB without risking corrupted input?</p>