Store correct query
'*' is a valid shell character
Stop trying to parse shell syntax

Instead of parsing things ourselves, outsource this to bash -nc, which
can do this a lot better.