You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common use-case of shlex.join is to get a shell-like invocation of a command.
In my experience, when writing small custom scripts, it is very common to use shlex.join in conjunction with subprocess.run, to log the command invocation to the output. subprocess.run has accepted path-like arguments since 3.6 on POSIX, and 3.8 on Windows, so when we want to use shutil.join, we need extra code to convert the path-like objects in the command sequence to strings.
It would be nice if shutil.join could receive the same command sequence as subprocess.run.
Yes, I actually didn't read the other issue entirely as it was marked as completed and not "not planned"!
I think the argument of "shlex.quote() takes a string, not a path (semantically)" also apply here then. shlex.join() joins shell arguments, not path components. Wouldn't shlex.join(map(str, split_command)) be sufficient?
While I can guess why subprocess.run() accepts path-like objects, shlex.join is (semantically) dedicated to lexical analysis. So... I'm rather -0 on this. What was the rationale for accepting path-like objects in subprocess.run()?
See #76142 for the rationale for subprocess.run(). There was still a long discussion that I haven't read yet though.
Feature or enhancement
Proposal:
A common use-case of
shlex.join
is to get a shell-like invocation of a command.In my experience, when writing small custom scripts, it is very common to use
shlex.join
in conjunction withsubprocess.run
, to log the command invocation to the output.subprocess.run
has accepted path-like arguments since 3.6 on POSIX, and 3.8 on Windows, so when we want to useshutil.join
, we need extra code to convert the path-like objects in the command sequence to strings.It would be nice if
shutil.join
could receive the same command sequence assubprocess.run
.Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
GH-72809 proposed this for
shlex.quote
.The text was updated successfully, but these errors were encountered: