File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed
Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,20 @@ if test -n "${ZSH_VERSION:-}" ; then
5252 fi
5353fi
5454
55+ # compgen -W doesn't work in some versions of zsh, so use this instead.
56+ # see https://www.zsh.org/mla/workers/2011/msg00582.html
57+ _compgen_w () {
58+ if test -n " ${ZSH_VERSION:- } " ; then
59+ typeset -a words
60+ words=( ${~=1} )
61+ local find=" $2 "
62+ results=(${(M)words[@]:# $find * } )
63+ echo " ${results[@]} "
64+ else
65+ compgen -W " $1 " -- " $2 "
66+ fi
67+ }
68+
5569# Bash programmable completion for Spack
5670_bash_completion_spack () {
5771 # In all following examples, let the cursor be denoted by brackets, i.e. []
@@ -137,7 +151,7 @@ _bash_completion_spack() {
137151 if [[ " $( LC_ALL=C type $subfunction 2>&1 ) " =~ $rgx ]]
138152 then
139153 $subfunction
140- COMPREPLY=($( compgen -W " $SPACK_COMPREPLY " -- " $cur " ) )
154+ COMPREPLY=($( _compgen_w " $SPACK_COMPREPLY " " $cur " ) )
141155 fi
142156
143157 # if every completion is an alias for the same thing, just return that thing.
@@ -359,7 +373,7 @@ _spack_compress_aliases() {
359373 fi
360374
361375 # get the alias of the first thing in the list of completions
362- _spack_get_alias " ${COMPREPLY[0] } "
376+ _spack_get_alias " ${COMPREPLY[@] : 0 : 1 } "
363377 local first_alias=" $SPACK_ALIAS "
364378
365379 # if anything in the list would alias to something different, stop
Original file line number Diff line number Diff line change @@ -52,6 +52,20 @@ if test -n "${ZSH_VERSION:-}" ; then
5252 fi
5353fi
5454
55+ # compgen -W doesn't work in some versions of zsh, so use this instead.
56+ # see https://www.zsh.org/mla/workers/2011/msg00582.html
57+ _compgen_w () {
58+ if test -n " ${ZSH_VERSION:- } " ; then
59+ typeset -a words
60+ words=( ${~=1} )
61+ local find=" $2 "
62+ results=(${(M)words[@]:# $find * } )
63+ echo " ${results[@]} "
64+ else
65+ compgen -W " $1 " -- " $2 "
66+ fi
67+ }
68+
5569# Bash programmable completion for Spack
5670_bash_completion_spack () {
5771 # In all following examples, let the cursor be denoted by brackets, i.e. []
@@ -137,7 +151,7 @@ _bash_completion_spack() {
137151 if [[ " $( LC_ALL=C type $subfunction 2>&1 ) " =~ $rgx ]]
138152 then
139153 $subfunction
140- COMPREPLY=($( compgen -W " $SPACK_COMPREPLY " -- " $cur " ) )
154+ COMPREPLY=($( _compgen_w " $SPACK_COMPREPLY " " $cur " ) )
141155 fi
142156
143157 # if every completion is an alias for the same thing, just return that thing.
@@ -359,7 +373,7 @@ _spack_compress_aliases() {
359373 fi
360374
361375 # get the alias of the first thing in the list of completions
362- _spack_get_alias " ${COMPREPLY[0] } "
376+ _spack_get_alias " ${COMPREPLY[@] : 0 : 1 } "
363377 local first_alias=" $SPACK_ALIAS "
364378
365379 # if anything in the list would alias to something different, stop
You can’t perform that action at this time.
0 commit comments