Skip to content

Fix ShellCheck findings in bin scripts (#1116) - #1120

Open
jarovarga wants to merge 2 commits into
cakephp:5.xfrom
jarovarga:ticket-1116-shellcheck
Open

jarovarga wants to merge 2 commits into
cakephp:5.xfrom
jarovarga:ticket-1116-shellcheck

Conversation

@jarovarga

Copy link
Copy Markdown
Contributor

Fixes #1116.

bin/bash_completion.sh

  • Declare the shell with # shellcheck shell=bash (SC2148).
  • Quote "${cur}" and "${prev}" in the compgen and completion subcommands calls (SC2086).
  • Replace [[ $COMPREPLY = "" ]] with [[ ${#COMPREPLY[@]} -eq 0 ]], so the whole array is checked (SC2128).

bin/cake

  • Remove the unused APP variable (SC2034).

The remaining SC2207 warnings are left as they are. ShellCheck suggests mapfile, which is not available in Bash 3.2, the macOS default, so using it would break completion there.

Tested under Bash 3.2.57 with a stub cake command: commands, subcommands, options and the _filedir fallback complete as before.

Declare the shell for the completion script, quote the expansions passed
to compgen and check the length of COMPREPLY instead of its first
element. Drop the unused APP variable from bin/cake.

The SC2207 warnings stay: mapfile is unavailable in Bash 3.2, the macOS
default.
Keep the COMPREPLY assignments, because mapfile is unavailable in
Bash 3.2, the macOS default, and silence SC2207 with a comment that
records the reason.
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.

ShellCheck findings in bin/bash_completion.sh and bin/cake

1 participant