-
Notifications
You must be signed in to change notification settings - Fork 391
refactor(_command_offset): save Bash's $2 passed to completion functions #814
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
Conversation
Even though this PR is huge and there is an interface change involved, I feel the code here is much easier to understand than in #791; from that point of view I have a better feeling about this one. If I understand correctly, the API change is such that it will mostly degrade gracefully, i.e. if the original arguments are not available, we'll basically do what we used to do before this change? Or will this flat out break some scenarios if not adjusted by affected completions? External completion authors will likely be using local cur prev words cword split comp_args
_init_completion -- "$@" || return ...in order to support earlier bash completion versions and to take advantage of the new stuff. |
OK! Then, let us consider this direction!
Yes, it is basically right. Actually, it slightly improves the original behavior. Originally, we passed the entire word
Ah, this is a good point. I hadn't noticed that point by myself. Thank you. |
Now `_comp_initialize` receives in its arguments the original arguments passed to the completion function. Arguments of other functions such as `_minimal`, `_longopt`, `_filedir_xspec`, `_known_hosts`, and `_user_at_host` are also changed.
dde3a00
to
fc4af85
Compare
Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's go with this. Thanks!
Fixes #790
This is a fix alternative to #791. Instead of imitating the arguments passed by Bash, we may save the original arguments in
_init_completion
(renamed to_comp_initialize
). However, this involves not only the change of_init_completion
itself but also the interface change of functions that call_init_completion
internally---such as_filedir_xspec
,_longopt
,_minimal
,_known_hosts
, etc. Also, this doesn't work when_comp_command_offset
is used without calling_init_completion
(some cases are found in external completions). We need to request external completion writers carefully update their code.