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

use shellcheck on generated bash completion script #261

Open
akeeman opened this issue Sep 21, 2022 · 0 comments
Open

use shellcheck on generated bash completion script #261

akeeman opened this issue Sep 21, 2022 · 0 comments
Milestone

Comments

@akeeman
Copy link

akeeman commented Sep 21, 2022

I suggest verifying the validity of a generated bash completion script using shellcheck. It would catch errors like mentioned in #260:

$ shellcheck <(poetry completions bash)

In /dev/fd/63 line 26:
        case "$com" in
        ^-- SC1009 (info): The mentioned syntax error was in this case expression.


In /dev/fd/63 line 40:
            (cache clear)
            ^-- SC1073 (error): Couldn't parse this case item. Fix to allow more checks.
                   ^-- SC1072 (error): Expected ) to open a new case item. Fix any mentioned problems and try again.
                   ^-- SC1085 (error): Did you forget to move the ;; after extending this case item?

For more information:
  https://www.shellcheck.net/wiki/SC1085 -- Did you forget to move the ;; aft...
  https://www.shellcheck.net/wiki/SC1072 -- Expected ) to open a new case ite...
  https://www.shellcheck.net/wiki/SC1073 -- Couldn't parse this case item. Fi...

once these are solved, shellcheck suggests some other non-critical changes:

$ shellcheck <(poetry completions bash)

In /dev/fd/63 line 1:
_poetry_6df9602aac65d588_complete()
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In /dev/fd/63 line 8:
    if [[ $(type -t ${words[0]}) == "alias" ]]; then
                    ^---------^ SC2154 (warning): words is referenced but not assigned (did you mean 'word'?).
                    ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(type -t "${words[0]}") == "alias" ]]; then


In /dev/fd/63 line 9:
        script=$(alias ${words[0]} | sed -E "s/alias ${words[0]}='(.*)'/\1/")
                       ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        script=$(alias "${words[0]}" | sed -E "s/alias ${words[0]}='(.*)'/\1/")


In /dev/fd/63 line 11:
        script=${words[0]}
        ^----^ SC2034 (warning): script appears unused. Verify use (or export if used externally).


In /dev/fd/63 line 15:
    for word in ${words[@]:1}; do
                ^-----------^ SC2068 (error): Double quote array expansions to avoid re-splitting elements.


In /dev/fd/63 line 182:
        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
                   ^-- SC2207 (warning): Prefer mapfile or read -a to split command output (or quote to avoid splitting).
                                             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))


In /dev/fd/63 line 189:
    if [[ $cur == $com ]]; then
                  ^--^ SC2053 (warning): Quote the right-hand side of == in [[ ]] to prevent glob matching.


In /dev/fd/63 line 192:
        COMPREPLY=($(compgen -W "${coms}" -- ${cur}))
                   ^-- SC2207 (warning): Prefer mapfile or read -a to split command output (or quote to avoid splitting).
                                             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        COMPREPLY=($(compgen -W "${coms}" -- "${cur}"))

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2034 -- script appears unused. Verify use...
@Secrus Secrus added this to the 2.1 milestone Jan 22, 2023
@Secrus Secrus modified the milestones: 2.1 , Future Aug 20, 2023
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