Chris Angelico <>:

> def shell_split(cmd):
>     return subprocess.check_output("""python -c 'import sys;
> print("\\0".join(sys.argv[1:]))' """+cmd,shell=True)[:-1].split(b"\0")
> You'll get back a list of byte strings, in any case. Feel free to pass
> them through a decode operation, or to incorporate a .decode() into
> the above stream, as you wish.

Now you are subject to the quirks of /bin/sh. For example, '*.xyz'
expands itself ('*.xyz') if there is no match in the current working

Moreover, you need to guard against arguments like

   $(cat ~/.ssh/id_dsa)

which would spill the beans.


Reply via email to