# bash parameter completion for the dotnet CLI

_dotnet_bash_complete()
{
  local word=${COMP_WORDS[COMP_CWORD]}

  local completions
  completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}")"

  COMPREPLY=( $(compgen -W "$completions" -- "$word") )
}

complete -f -F _dotnet_bash_complete dotnet

# bash parameter completion for the dotnet CLI

_dotnet_bash_complete()
{
  local word=${COMP_WORDS[COMP_CWORD]}

  local completions
  completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)"
  if [ $? -ne 0 ]; then
    completions=""
  fi

  COMPREPLY=( $(compgen -W "$completions" -- "$word") )
}

complete -f -F _dotnet_bash_complete dotnet

Fix bash completion when the SDK is not installed
Fix bash completion when the SDK is not installed

The `dotnet complete` command is an SDK command. If the SDK is not
installed, `dotnet complete` is not available. Triggering completion in
bash without the SDK installed results in errors being shown.

Fix it by checking the exit status of `dotnet complete` before trying to
use to for completions. If the SDK is not installed, we will only show
file completions.

Fixes #11044
