bash-completion-tutorial
bash-completion-tutorial copied to clipboard
Need IFS=$'\n' earlier in the tutorial
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".
So, this works:
_dothis_completions()
{
local IFS=$'\n'
COMPREPLY=($(compgen -W "$(fc -l -50 | sed 's/\t//g')" -- "${COMP_WORDS[1]}"))
}