Skip to content

Split PAGER and EDITOR with a Windows-specific shlex equivalent - #3880

Draft
kdeldycke wants to merge 1 commit into
pallets:stablefrom
kdeldycke:windows-command-line-split
Draft

kdeldycke wants to merge 1 commit into
pallets:stablefrom
kdeldycke:windows-command-line-split

Conversation

@kdeldycke

@kdeldycke kdeldycke commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

When I implemented #3777 a couple of weeks ago, I was annoyed by Windows behavior. And wondered why shlex.split is only available on Unix-like platforms. Then while cleaning ancient Python 2 stuff in https://github.com/pallets/click/pull/3817/changes#diff-3bd2075eb8cab59a601f5a021078e5763eea117ae315b04d8d2d719de1f45a97R48 , I discovered CommandLineToArgvW.

This is an attempt to rely on CommandLineToArgvW, which seems to do the trick, as a Windows equivalent to shlex.split.

But digging deeper I stumbled upon the discussion upstream at python/cpython#44990 (comment) , which explain why it was not considered for inclusion in the Python stdlib:

on Windows, there isn't a single "shell syntax" to target - PowerShell and CMD have very different quoting rules, etc, and the fact that commands can do their own command line parsing (they get passed a command line string rather than an argument array) adds even more complexity.

And that explain why this PRs has limits, and why I choose to keep the shell completion relying on shlex.

I propose this PR anyway as it seems to bring the behavior more in line with Windows default, but kept as draft as I need a bit of feedback about this attempt.

Tests

I collected test cases from past discussions to build up a more comprehensive suite:

@kdeldycke
kdeldycke marked this pull request as draft September 24, 2026 15:09
@kdeldycke kdeldycke added windows Windows-specific behavior shell completion Shell tab completion labels Sep 24, 2026
@kdeldycke kdeldycke added this to the 8.5.1 milestone Sep 24, 2026
@kdeldycke
kdeldycke force-pushed the windows-command-line-split branch from 8d17dc0 to d2a4dc2 Compare September 24, 2026 15:23

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shell completion Shell tab completion windows Windows-specific behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant