bash-completion-tutorial icon indicating copy to clipboard operation
bash-completion-tutorial copied to clipboard

Need IFS=$'\n' earlier in the tutorial

Open BradleySmall opened this issue 6 years ago • 1 comments

When working through the tutorial, once you begin using fc -l... in the completion script. You neglect to add the IFS=$'\n' to the script. This results in each command and number being broken apart into multiple unrelated "arguments".

BradleySmall avatar Mar 13 '19 17:03 BradleySmall

So, this works:

_dothis_completions()
{
    local IFS=$'\n'
    COMPREPLY=($(compgen -W "$(fc -l -50 | sed 's/\t//g')" -- "${COMP_WORDS[1]}"))
}

d4rwel avatar May 24 '20 10:05 d4rwel