[Python-Dev] shellwords

Gustavo Niemeyer niemeyer@conectiva.com
Sat, 19 Apr 2003 19:51:08 -0300


> It's already there (and has been since Python 1.6), albeit with a
> different name and implementation:
> 
> >>> import distutils.util
> >>> distutils.util.split_quoted('arg "arg arg" arg "arg" -o="arg arg"')
> ['arg', 'arg arg', 'arg', 'arg', '-o=arg arg']

I wasn't aware about it. While it should be enough for most uses, it's
still not posix compliant.  Single and double quotes are treated the
same way (single quotes shouldn't allow escaping), and escaping is done
differently (r'"\""' results in r'\"' instead of '"', and r'"\\"'
results in r'\\' instead of r'\', for example).

As others have said, it'd be nice to have these utilities somewhere
outside distutils.

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]