Skip to content
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

fix: fix completion for sh/bash/zsh #47

Merged
merged 2 commits into from
Sep 12, 2023
Merged

fix: fix completion for sh/bash/zsh #47

merged 2 commits into from
Sep 12, 2023

Conversation

toumorokoshi
Copy link
Owner

issue #43 reported compgen failing on completion parameters that looked like they were command line switches (e.g. "--")

This looks to be due to incorrect usage of compgen, where the difference between options and the user's completion to complete were not separated with the "--" delimiter. According to getopt(1) documentation this should be split explicitly:

   When the end of options is encountered, the getopts utility shall
   exit with a return value greater than zero; the shell variable
   OPTIND shall be set to the index of the first operand, or the
   value "$#"+1 if there are no operands; the name variable shall be
   set to the <question-mark> character. Any of the following shall
   identify the end of options: the first "--" argument that is not
   an option-argument, finding an argument that is not an option-
   argument and does not begin with a '-', or encountering an error.

This fixes the issue when reproing locally.

issue #43 reported compgen failing on completion parameters
that looked like they were command line switches (e.g. "--")

This looks to be due to incorrect usage of compgen, where the difference
between options and the user's completion  to complete were not separated with
the "--" delimiter. According to getopt(1) documentation this should be
split explicitly:

       When the end of options is encountered, the getopts utility shall
       exit with a return value greater than zero; the shell variable
       OPTIND shall be set to the index of the first operand, or the
       value "$#"+1 if there are no operands; the name variable shall be
       set to the <question-mark> character. Any of the following shall
       identify the end of options: the first "--" argument that is not
       an option-argument, finding an argument that is not an option-
       argument and does not begin with a '-', or encountering an error.

This fixes the issue when reproing locally.
@toumorokoshi toumorokoshi merged commit c19e251 into master Sep 12, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant