Shell-escape searches
Shell-escape searches

I found that doing a search with parens was falling foul of shell
escaping issues:

  Query: from:greg (ruby NEAR version)
  sh: -c: line 0: syntax error near unexpected token `('
  sh: -c: line 0: `{ notmuch search --output=files from:greg (ruby NEAR version); } 2>&1'

The solution is to shell escape, using `shlex.quote` when available (ie.
Python 3.3), and `pipes.quote` otherwise:

-  https://docs.python.org/3/library/shlex.html#shlex.quote
-  https://docs.python.org/2/library/pipes.html#pipes.quote

As the `pipes.doc` docs say:

> Deprecated since version 2.7: Prior to Python 2.7, this function was
> not publicly documented. It is finally exposed publicly in Python
> 3.3 as the `quote` function in the `shlex` module.

So I am doing a `try`/`except` style of import.

honza/mutt-notmuch-py