How can I reverse the results of a shlex.split? That is, how can I obtain a quoted string that would \"resemble that of a Unix shell\", given a list
of strings
There is a feature request for adding shlex.join()
, which would do exactly what you ask. As of now, there does not seem any progress on it, though, mostly as it would mostly just forward to shlex.quote()
. In the bug report, a suggested implementation is mentioned:
' '.join(shlex.quote(x) for x in split_command)
See https://bugs.python.org/issue22454