[PATCH 4 of 5] bash_completion: small cleanup and bugfix

Alexis S. L. Carvalho alexis at cecm.usp.br
Sun Aug 28 20:43:16 CDT 2005


# HG changeset patch
# User Alexis S. L. Carvalho <alexis at cecm.usp.br>
# Node ID eb61cf03131f6f08d9c68dd22a8d56a790c49008
# Parent  93433c2989a15f3ca3b60799590b0a41c500a97f
bash_completion: small cleanup and bugfix

_hg_count_non_option wasn't taking global options into account 
while counting non-option arguments.

It also used only its first argument.

diff -r 93433c2989a1 -r eb61cf03131f contrib/bash_completion
--- a/contrib/bash_completion	Mon Aug 29 01:12:06 2005
+++ b/contrib/bash_completion	Mon Aug 29 01:12:06 2005
@@ -41,11 +41,9 @@
 
     for (( i=1; $i<=$COMP_CWORD; i++ )); do
 	if [[ "${COMP_WORDS[i]}" != -* ]]; then
-	    for f in $filters; do
-		if [[ ${COMP_WORDS[i-1]} == $f ]]; then
-		    continue 2
-		fi
-	    done
+	    if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then
+		continue
+	    fi
 	    count=$(($count + 1))
 	fi
     done
@@ -154,7 +152,7 @@
 	    COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -X "!*.d" -- "$cur" ))
 	;;
 	cat)
-	    local count=$(_hg_count_non_option -o --output)
+	    local count=$(_hg_count_non_option '-o|--output')
 	    if [ $count = 2 ]; then
 		_hg_tags
 	    else


More information about the Mercurial mailing list