From: Felipe Contreras Date: Sat, 17 Nov 2012 11:39:24 GMT Subject: Re: [PATCH 6/7] completion: fix expansion issue in __gitcomp() Message-ID: In-Reply-To: <1353150353-29874-7-git-send-email-szeder@ira.uka.de> On Sat, Nov 17, 2012 at 12:05 PM, SZEDER Gábor wrote: > -# Generates completion reply with compgen, appending a space to possible > -# completion words, if necessary. > +# Generates completion reply for the word in $cur, appending a space to > +# possible completion words, if necessary. > # It accepts 1 to 4 arguments: > # 1: List of possible completion words. > # 2: A prefix to be added to each possible completion word (optional). > -# 3: Generate possible completion matches for this word (optional). > +# 3: Generate possible completion matches for this word instead of $cur > +# (optional). > # 4: A suffix to be appended to each possible completion word (optional). > __gitcomp () > { > @@ -241,10 +242,22 @@ __gitcomp () > COMPREPLY=() > ;; > *) > - local IFS=$'\n' > - COMPREPLY=($(compgen -P "${2-}" \ > - -W "$(__gitcomp_1 "${1-}" "${4-}")" \ > - -- "$cur_")) > + local i=0 c IFS=$' \t\n' > + for c in $1; do > + case $c in > + "$cur_"*) > + c="$c${4-}" > + case $c in > + --*=*|*.) ;; > + *) c="$c " ;; > + esac > + COMPREPLY[$i]="${2-}$c" > + i=$((++i)) > + ;; > + *) > + ;; > + esac > + done This is not quite the same as before, is it? Before the suffix would be taken into consideration for the comparison with $cur_, but not any more. Cheers. -- Felipe Contreras