Skip to content

modernize completion for bash #27828

@gaelicWizard

Description

@gaelicWizard

I would suggest a slightly more modern formulation for the completion:

function _dotnet_bash_complete()
{
  local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n'
  local candidates

  read -d '' -ra candidates < <(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)

  read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]:-}" -- "$cur")
}

This uses a more familiar convention to many programmable completion functions for Bash, is more idiomatic Bash, and avoids unexpected word-splitting by being explicit about it: use read -ra to populate the array parameter, with IFS=$'\n' and -d ''.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions