Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
completion: don't break global COMP_WORDBREAKS
As described in #4530, #5820 modification of global variable
COMP_WORDBREAKS causes global breakage of completion:

```
dd if=/dev/ze<tab>
->
dd /dev/zero
```

Fixes: #4530

PR-URL: #8892
  • Loading branch information
Greg Whiteley authored and iarna committed Aug 7, 2015
1 parent 9a3de6e commit 04ec77b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/utils/completion.sh
Expand Up @@ -7,17 +7,21 @@
# 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 words cword
if type _get_comp_words_by_ref &>/dev/null; then
_get_comp_words_by_ref -n = -n @ -w words -i cword
else
cword="$COMP_CWORD"
words=("${COMP_WORDS[@]}")
fi

local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_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"
}
Expand Down

0 comments on commit 04ec77b

Please sign in to comment.