Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions bin/bash_completion.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# shellcheck shell=bash
#
# Bash completion file for CakePHP console.
# 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
Expand All @@ -21,20 +23,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
Expand Down
1 change: 0 additions & 1 deletion bin/cake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down