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

Completion scripts have redundant case statement #470

Closed
dwalluck opened this issue Sep 7, 2018 · 5 comments
Closed

Completion scripts have redundant case statement #470

dwalluck opened this issue Sep 7, 2018 · 5 comments
Milestone

Comments

@dwalluck
Copy link
Contributor

dwalluck commented Sep 7, 2018

I believe that we can simplify the competition scripts by using one case statement instead of two without losing any functionality. Replace:

case ${CURR_WORD} in
    foo)
      COMPREPLY=( $( compgen -- "" ) )
      return $?
      ;;
     *)
      case ${PREV_WORD} in
        foo)
          COMPREPLY=( $( compgen  -- "${CURR_WORD}" ) )
          ;;
    esac
esac

with

case ${PREV_WORD} in
    foo)
      COMPREPLY=( $( compgen -- "${CURR_WORD}" ) )
      return $?
      ;;
esac
@dwalluck
Copy link
Contributor Author

dwalluck commented Sep 8, 2018

This also seems to make competition of short options with an argument not complete correctly, although the long option version work.

@remkop
Copy link
Owner

remkop commented Sep 8, 2018

I am a bit worried about regressions, so I want to test this one extra carefully but otherwise no objections.

@dwalluck
Copy link
Contributor Author

dwalluck commented Sep 8, 2018

It will fix the option argument handling, which I believe was a pre-existing bug. I have a pull request ready, but it's on top of #469.

@dwalluck
Copy link
Contributor Author

dwalluck commented Sep 8, 2018

I didn't see any regressions, but the following behavior is improved:

ARG_OPTS="-f --foo"
FOO_OPTION_ARGS="bar baz"

Then, --foo<TAB><TAB> always worked (and showed the options and allowed completing them), but -f<TAB><TAB> was showing bar baz but not complementing them (as a space is not being added after -f to trigger the competition).

@remkop remkop added this to the 3.6 milestone Sep 9, 2018
remkop added a commit that referenced this issue Sep 9, 2018
…short options with arguments (generate completions)
@remkop
Copy link
Owner

remkop commented Sep 9, 2018

Confirmed and merged. Nice work!

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

No branches or pull requests

2 participants