Skip to content

Commit 6e9a9ff

Browse files
authored
Update bash syntax for auto-complete (#29808)
Per #27828.
1 parent bc974ab commit 6e9a9ff

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

docs/core/tools/enable-tab-autocomplete.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,14 @@ To add tab completion to your **bash** shell for the .NET CLI, add the following
6161
```bash
6262
# bash parameter completion for the dotnet CLI
6363

64-
_dotnet_bash_complete()
64+
function _dotnet_bash_complete()
6565
{
66-
local word=${COMP_WORDS[COMP_CWORD]}
66+
local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n'
67+
local candidates
6768

68-
local completions
69-
completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)"
70-
if [ $? -ne 0 ]; then
71-
completions=""
72-
fi
69+
read -d '' -ra candidates < <(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)
7370

74-
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
71+
read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]:-}" -- "$cur")
7572
}
7673

7774
complete -f -F _dotnet_bash_complete dotnet

0 commit comments

Comments
 (0)