From a1b3bb03ed7f7339ba7a03db0bbf8e5ca35eef95 Mon Sep 17 00:00:00 2001 From: Mario Schwalbe Date: Thu, 8 Sep 2022 19:03:29 +0200 Subject: [PATCH] * Fix handling of CLI_ARGS --- completion/bash/task.bash | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/completion/bash/task.bash b/completion/bash/task.bash index f1622111..de93e4c8 100644 --- a/completion/bash/task.bash +++ b/completion/bash/task.bash @@ -7,6 +7,18 @@ function _task() local cur prev words cword _init_completion -n : || return + # Check for `--` within command-line and quit or strip suffix. + local i + for i in "${!words[@]}"; do + if [ "${words[$i]}" == "--" ]; then + # Do not complete words following `--` passed to CLI_ARGS. + [ $cword -gt $i ] && return + # Remove the words following `--` to not put --list in CLI_ARGS. + words=( "${words[@]:0:$i}" ) + break + fi + done + # Handle special arguments of options. case "$prev" in -d|--dir) @@ -33,7 +45,7 @@ function _task() esac # Prepare task name completions. - local tasks=( $( "${COMP_WORDS[@]}" --silent $_GO_TASK_COMPLETION_LIST_OPTION 2> /dev/null ) ) + local tasks=( $( "${words[@]}" --silent $_GO_TASK_COMPLETION_LIST_OPTION 2> /dev/null ) ) COMPREPLY=( $( compgen -W "${tasks[*]}" -- "$cur" ) ) # Post-process because task names might contain colons.