-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Shell completion does't parse escaped slashes or spaces correctly #1708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I've updated the issue with a simpler example and direct explanations for expected and actual behavior. The issue seems to be with how Adding some debugging code to
The shell is passing You can find some other weird behaviors by tab completing earlier, or with a single opening quote, or within quotes. The splitter should be able to handle these. That's about the extent of the time I can devote to this for now though. Your best bet for getting this fixed before 8.0 is released is to make a PR. |
Ok, thanks. Yes, that example was a bit of a mess. From a quick look, |
Because shlex.split("example my\\") ValueError: No escaped character shlex.split("example 'my ") ValueError: No closing quotation |
You might be able to get around that by manually iterating over a |
I was about to propose exactly that! Any remainder after a |
Those two examples should be the only cases where |
Hopefully. Also, unpaired quotes should ideally be preserved during the completion process: An input of I'll need to think a bit about this and see if can submit a PR that fixes more than it breaks. But not tonight, it's already late here. |
When a value with an escape string, for instance
my\ file
, is passed to aclick.ParamType
, theincomplete
value which is passed toclick.ParamType.shell_complete
will only be"my\ "
instead ofmy file
.Expected Behavior
Completing
my\ f
should be interpreted as the Python string"my f"
and match the first two values.Actual Behavior
Completing
my\ f
is interpreted as the string"my\\ f"
and matches the third value.Environment
The text was updated successfully, but these errors were encountered: