[Pkg-javascript-devel] Bug#711810: npm: bash completion script clobbers $COMP_WORDBREAKS

Jérémy Lal kapouer at melix.org
Tue Aug 5 22:28:44 UTC 2014


Package: npm
Version: 1.4.21+ds-1
Followup-For: Bug #711810

The problem i have with this completion code is that i don't know
which part is actually useful on debian.
I guessed the first part only need to be fixed - but i'm not even
sure it works. I don't know in which cases the @ or = symbols are
significant.
Anyway, here's a start. Anyone with better knowledge of bash_completion
is welcome to help.

-- Configuration Files:
/etc/bash_completion.d/npm changed:
if type complete &>/dev/null; then
  _npm_completion () {
    local si cur prev words cword
    si="$IFS"
    _get_comp_words_by_ref -n @= words cword
    IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
                           COMP_LINE="$COMP_LINE" \
                           COMP_POINT="$COMP_POINT" \
                           npm completion -- "${words[@]}" \
                           2>/dev/null)) || return $?
    IFS="$si"
  }
  complete -F _npm_completion npm
elif type compdef &>/dev/null; then
  COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
  COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
  export COMP_WORDBREAKS
  _npm_completion() {
    si=$IFS
    compadd -- $(COMP_CWORD=$((CURRENT-1)) \
                 COMP_LINE=$BUFFER \
                 COMP_POINT=0 \
                 npm completion -- "${words[@]}" \
                 2>/dev/null)
    IFS=$si
  }
  compdef _npm_completion npm
elif type compctl &>/dev/null; then
  _npm_completion () {
    COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
    COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
    export COMP_WORDBREAKS
    local cword line point words si
    read -Ac words
    read -cn cword
    let cword-=1
    read -l line
    read -ln point
    si="$IFS"
    IFS=$'\n' reply=($(COMP_CWORD="$cword" \
                       COMP_LINE="$line" \
                       COMP_POINT="$point" \
                       npm completion -- "${words[@]}" \
                       2>/dev/null)) || return $?
    IFS="$si"
  }
  compctl -K _npm_completion npm
fi


-- no debconf information



More information about the Pkg-javascript-devel mailing list