I want \"git log --format=\'(%h) %s\' --abbrev=7 HEAD\"
to be split into
[
\"git\",
\"log\",
\"--format=\'(%h) %s\'\",
\"--abbrev=7\",
\
I found one possible (albeit ugly) solution in python (which also works with "
):
>>> import re
>>> foo = '''git log --format='(%h) %s' --foo="a b" --bar='c d' HEAD'''
>>> re.findall(r'''(\S*'[^']+'\S*|\S*"[^"]+"\S*|\S+)''', foo)
['git', 'log', "--format='(%h) %s'", '--foo="a b"', "--bar='c d'", 'HEAD']