title: "Unquote"/parse bash argument string in python
body: <p>I have a python script that takes its input from the command line arguments. For example:</p>
  
  <pre><code>./myscript.py first_item second\ item "third item"
  </code></pre>
  
  <p>I can output separate items and escape spaces and special characters using <a href="http://docs.python.org/2/library/pipes.html" rel="nofollow"><code>pipes.quote</code></a>.</p>
  
  <pre><code>print " ".join(map(pipes.quote, outputItems))
  </code></pre>
  
  <p><em>Is there any existing "<code>unquote</code>" interface that will parse a bash argument string, keeping escaped spaces and quoted strings intact?</em></p>
  
  <p>Something that would allow the same python script to handle this:</p>
  
  <pre><code>echo 'first_item second\ item "third item"' | ./myscript.py
  </code></pre>