This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2014年09月21日 19:35 by deleted250130, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 7605 | merged | bbayles, 2018年06月10日 22:59 | |
| Messages (10) | |||
|---|---|---|---|
| msg227228 - (view) | Author: (deleted250130) | Date: 2014年09月21日 19:35 | |
There is currently shlex.split() that is for example useful to split a command string and pass it to subprocess.Popen with shell=False. But I'm missing a function that does the opposite: Building the command string from a list that could for example then be used in subprocess.Popen with shell=True. |
|||
| msg227235 - (view) | Author: Ben Roberts (roippi) * | Date: 2014年09月21日 20:23 | |
' '.join(shlex.quote(x) for x in split_command) |
|||
| msg227239 - (view) | Author: (deleted250130) | Date: 2014年09月21日 21:26 | |
Yes, it is possible to do this with a few other commands. But I think it would be still a nice enhancement to have a direct function for it. |
|||
| msg227244 - (view) | Author: Ben Roberts (roippi) * | Date: 2014年09月22日 00:08 | |
For the record I am on board with a shlex.join. Even though the implementation is simple: - It is not obvious to many users if there are any "gotchas" by doing a ' '.join yourself, /even if/ you know that strings with spaces in them need to pass through shlex.quote first. - The symmetry of shlex.split and shlex.join is obvious - I don't need to read any documentation to know that they are inverse operations. - "batteries included," "one obvious way," and all that. |
|||
| msg318816 - (view) | Author: Cheryl Sabella (cheryl.sabella) * (Python committer) | Date: 2018年06月06日 12:37 | |
Hi Vinay, You made the most recent changes to shlex, so I was wondering what you thought of this suggestion. Thanks! |
|||
| msg318817 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2018年06月06日 12:59 | |
I like it, myself, though there is some danger in promoting the idea that this is a "safe" operation. It theoretically should be, but it increases the attack surface slightly if you actually use it (that is, using shell=False is always safer, by at least a small margin). Maybe a mention of that in the docs would be enough, though. |
|||
| msg318911 - (view) | Author: Vinay Sajip (vinay.sajip) * (Python committer) | Date: 2018年06月07日 08:05 | |
I'm +0 on the idea. |
|||
| msg318913 - (view) | Author: Matthijs Kooijman (Matthijs Kooijman) | Date: 2018年06月07日 08:14 | |
One usecase that such a function would be well-suited for is for *displaying* commands being executed. Then, the commands will be executed as a command+args array, but can be displayed unambiguously in log output. |
|||
| msg343872 - (view) | Author: Vinay Sajip (vinay.sajip) * (Python committer) | Date: 2019年05月29日 08:06 | |
New changeset ca804955927dddb6ae5a846dbc0248a932be9a4e by Vinay Sajip (Bo Bayles) in branch 'master': bpo-22454: Add shlex.join() (the opposite of shlex.split()) (GH-7605) https://github.com/python/cpython/commit/ca804955927dddb6ae5a846dbc0248a932be9a4e |
|||
| msg351257 - (view) | Author: Daniel Himmelstein (dhimmel) * | Date: 2019年09月06日 14:43 | |
I am interested in shlex.join as a way to log subprocess.CompletedProcess.args as a string that users could run in their terminals. I initially assumed that this was also the scope of shlex.join. However, it seems that shlex.join does not accept all types of command arguments supported by subprocess, such as pathlib.Path objects. Should shlex.join support an split_command list that includes pathlib.Path objects and any other types supported by subprocess? |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:08 | admin | set | github: 66644 |
| 2019年09月06日 14:43:48 | dhimmel | set | nosy:
+ dhimmel messages: + msg351257 |
| 2019年05月29日 17:09:06 | berker.peksag | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2019年05月29日 08:06:21 | vinay.sajip | set | messages: + msg343872 |
| 2019年04月17日 16:06:10 | terry.reedy | set | versions: + Python 3.8, - Python 3.5 |
| 2019年04月11日 18:55:05 | p-ganssle | set | nosy:
+ p-ganssle |
| 2018年06月10日 23:00:55 | bbayles | set | nosy:
+ bbayles |
| 2018年06月10日 22:59:07 | bbayles | set | keywords:
+ patch stage: patch review pull_requests: + pull_request7228 |
| 2018年06月07日 08:14:46 | Matthijs Kooijman | set | messages: + msg318913 |
| 2018年06月07日 08:05:22 | vinay.sajip | set | messages: + msg318911 |
| 2018年06月06日 12:59:58 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg318817 |
| 2018年06月06日 12:37:02 | cheryl.sabella | set | nosy:
+ vinay.sajip, cheryl.sabella messages: + msg318816 |
| 2018年04月25日 13:01:11 | Matthijs Kooijman | set | nosy:
+ Matthijs Kooijman |
| 2014年09月22日 00:08:21 | roippi | set | messages:
+ msg227244 versions: + Python 3.5, - Python 3.4 |
| 2014年09月21日 21:26:34 | deleted250130 | set | messages: + msg227239 |
| 2014年09月21日 20:23:19 | roippi | set | nosy:
+ roippi messages: + msg227235 |
| 2014年09月21日 19:35:49 | deleted250130 | create | |