Skip to content

Commit a574b51

Browse files
NariyasuHeseriwraithgar
authored andcommitted
fix(completion): restore IFS even if npm completion returns error
PR-URL: #3304 Credit: @NariyasuHeseri Close: #3304 Reviewed-by: @wraithgar
1 parent dbbc151 commit a574b51

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/utils/completion.sh

+13-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ if type complete &>/dev/null; then
1818
fi
1919

2020
local si="$IFS"
21-
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
21+
if ! IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
2222
COMP_LINE="$COMP_LINE" \
2323
COMP_POINT="$COMP_POINT" \
2424
npm completion -- "${words[@]}" \
25-
2>/dev/null)) || return $?
25+
2>/dev/null)); then
26+
local ret=$?
27+
IFS="$si"
28+
return $ret
29+
fi
2630
IFS="$si"
2731
if type __ltrim_colon_completions &>/dev/null; then
2832
__ltrim_colon_completions "${words[cword]}"
@@ -49,11 +53,16 @@ elif type compctl &>/dev/null; then
4953
read -l line
5054
read -ln point
5155
si="$IFS"
52-
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
56+
if ! IFS=$'\n' reply=($(COMP_CWORD="$cword" \
5357
COMP_LINE="$line" \
5458
COMP_POINT="$point" \
5559
npm completion -- "${words[@]}" \
56-
2>/dev/null)) || return $?
60+
2>/dev/null)); then
61+
62+
local ret=$?
63+
IFS="$si"
64+
return $ret
65+
fi
5766
IFS="$si"
5867
}
5968
compctl -K _npm_completion npm

0 commit comments

Comments
 (0)