From cb91c91cf7f699e2c3bc96f1e201af6b844974f5 Mon Sep 17 00:00:00 2001 From: Jaro Varga Date: Sun, 18 Oct 2026 19:11:25 +0200 Subject: [PATCH 1/2] Fix ShellCheck findings in bin scripts (#1116) 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. --- bin/bash_completion.sh | 11 ++++++----- bin/cake | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/bash_completion.sh b/bin/bash_completion.sh index 319059e694..0583292044 100644 --- a/bin/bash_completion.sh +++ b/bin/bash_completion.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # # Bash completion file for CakePHP console. # Copy this file to a file named `cake` under `/etc/bash_completion.d/`. @@ -21,20 +22,20 @@ _cake() opts=$(${cake} completion options "${COMP_WORDS[1]}" "${COMP_WORDS[2]}") fi - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi if [[ ${COMP_CWORD} = 1 ]] ; then opts=$(${cake} completion commands) - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi if [[ ${COMP_CWORD} = 2 ]] ; then - opts=$(${cake} completion subcommands $prev) - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - if [[ $COMPREPLY = "" ]] ; then + opts=$(${cake} completion subcommands "${prev}") + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + if [[ ${#COMPREPLY[@]} -eq 0 ]] ; then _filedir return 0 fi diff --git a/bin/cake b/bin/cake index 4b696c883f..6ad1112b66 100755 --- a/bin/cake +++ b/bin/cake @@ -56,7 +56,6 @@ then fi CONSOLE=$(dirname -- "$(canonicalize "$realname")") -APP=$(dirname "$CONSOLE") # If your CLI PHP is somewhere that this doesn't find, you can define a PHP environment # variable with the correct path in it. From 5baf6e3b49de76b24bef5ca402105e438b8d46e1 Mon Sep 17 00:00:00 2001 From: Jaro Varga Date: Sun, 18 Oct 2026 23:26:09 +0200 Subject: [PATCH 2/2] Explain why the SC2207 findings stay in the completion script 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. --- bin/bash_completion.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/bash_completion.sh b/bin/bash_completion.sh index 0583292044..17663d8c24 100644 --- a/bin/bash_completion.sh +++ b/bin/bash_completion.sh @@ -4,7 +4,8 @@ # Copy this file to a file named `cake` under `/etc/bash_completion.d/`. # For more info check https://book.cakephp.org/5/en/console-commands/completion.html#how-to-enable-bash-autocompletion-for-the-cakephp-console # - +# Keep `COMPREPLY=( $(compgen ...) )`, because mapfile is unavailable in Bash 3.2, the macOS default. +# shellcheck disable=SC2207 _cake() { local cur prev opts cake