Closed AlexWaygood closed 9 months ago
Is the issue that shlex.quote prefers single quotes instead of double quotes?
I think that's the main issue, yeah, though I don't really know much more than what the warning in the docs tells me.
This solution is derived from Eryk Sun's comments on a Stack Overflow question that suggest that this should always do the right thing if all you need to do is to quote a Windows path, and it was the quoting of paths that was causing me grief locally.
An alternative solution would be to use subprocess.list2cmdline
, which I think tries harder to capture all the semantics of the Windows command line. I didn't go for that because:
I set out to figure out why the changes I made in #97 caused primer to hang in typeshed's CI, but quickly realised that I couldn't run primer locally at all any more! This is because
shlex.quote()
does the wrong thing on Windows when you pass it a path. All you actually need to do on Windows to quote a path is to do some basic validation and then surround it with""
, so there's a pretty simple workaround.