Adding a patch as it is more appropriate for collaboration.

--- ../pkg-javascript/lib/utils/completion.sh	2014-08-06 00:30:33.000000000 +0200
+++ bash_completion_npm_711810	2014-08-06 00:23:31.208226950 +0200
@@ -1,3 +1,4 @@
+#!/bin/bash
 ###-begin-npm-completion-###
 #
 # npm command completion script
@@ -6,22 +7,25 @@
 # Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm
 #
 
-COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
-COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
-export COMP_WORDBREAKS
+
 
 if type complete &>/dev/null; then
   _npm_completion () {
-    local si="$IFS"
-    IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
+    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 -- "${COMP_WORDS[@]}" \
+                           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)) \
@@ -34,6 +38,9 @@
   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

Reply via email to