diff --git a/docs/core/tools/enable-tab-autocomplete.md b/docs/core/tools/enable-tab-autocomplete.md index 2ca11e6fc3e33..a132e17d9add4 100644 --- a/docs/core/tools/enable-tab-autocomplete.md +++ b/docs/core/tools/enable-tab-autocomplete.md @@ -61,17 +61,14 @@ To add tab completion to your **bash** shell for the .NET CLI, add the following ```bash # bash parameter completion for the dotnet CLI -_dotnet_bash_complete() +function _dotnet_bash_complete() { - local word=${COMP_WORDS[COMP_CWORD]} + local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n' + local candidates - local completions - completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)" - if [ $? -ne 0 ]; then - completions="" - fi + read -d '' -ra candidates < <(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null) - COMPREPLY=( $(compgen -W "$completions" -- "$word") ) + read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]:-}" -- "$cur") } complete -f -F _dotnet_bash_complete dotnet