[Bash-completion-commits] [SCM] bash-completion branch, master, updated. f1f03cd9dcfc14836d302fd87f9d5df72012ad7d

Ville Skyttä ville.skytta at iki.fi
Thu Apr 30 15:59:36 UTC 2009


The following commit has been merged in the master branch:
commit f1f03cd9dcfc14836d302fd87f9d5df72012ad7d
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Thu Apr 30 18:59:23 2009 +0300

    Improve built in ant completion.

diff --git a/CHANGES b/CHANGES
index 7d83356..9219de3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -45,7 +45,7 @@ bash-completion (1.x)
   * Add make --old/new-file, --assume-old/new, --what-if value completions.
   * Add smartctl -n/--nocheck completion, add more other value completions.
   * Fix leaking $prev from mkinitrd completion.
-  * Split ant completion to contrib/ant.
+  * Split ant completion to contrib/ant, improve the built in one.
 
   [ Todd Zullinger ]
   * Make yum complete on filenames after install, deplist, update and upgrade
diff --git a/contrib/ant b/contrib/ant
index a73b683..8641705 100644
--- a/contrib/ant
+++ b/contrib/ant
@@ -13,27 +13,41 @@ _ant()
 	prev=${COMP_WORDS[COMP_CWORD-1]}
 
 	case "$prev" in
-		-buildfile|-f)
+		-buildfile|-file|-f)
 			_filedir 'xml'
 			return 0
 			;;
-		-logfile)
+		-logfile|-l)
 			_filedir
 			return 0
 			;;
+		-propertyfile)
+			_filedir properties
+			return 0
+			;;
+		-nice)
+			COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9 10' \
+				-- $cur ) )
+			return 0
+			;;
+		-lib|-logger|-listener|-D|-inputhandler|-main)
+			return 0
+			;;
 	esac
 
 	if [[ "$cur" == -* ]]; then
-		# relevant options completion
-		COMPREPLY=( $( compgen -W '-help -projecthelp -version -quiet \
-			       -verbose -debug -emacs -logfile -logger \
-			       -listener -buildfile -f -D -find' -- $cur ) )
+		COMPREPLY=( $( compgen -W '-help -h -projecthelp -p -version \
+			-diagnostics -quiet -q -verbose -v -debug -d -emacs -e \
+			-lib -logfile -l -logger -listener -noinput -buildfile \
+			-file -f -D -keep-going -k -propertyfile -inputhandler \
+			-find -s -nice -nouserlib -noclasspath -autoproxy \
+			-main' -- $cur ) )
 	else
 		# available targets completion
 		# find which buildfile to use
 		buildfile=build.xml
 		for (( i=1; i < COMP_CWORD; i++ )); do
-			if [[ "${COMP_WORDS[i]}" == -buildfile ]]; then
+			if [[ "${COMP_WORDS[i]}" == -@(?(build)file|f) ]]; then
 				buildfile=${COMP_WORDS[i+1]}
 				break
 			fi
@@ -41,12 +55,12 @@ _ant()
 		[ ! -f $buildfile ] && return 0
 
 		# parse buildfile for targets
-		COMPREPLY=( $( awk -F'"' '/<target name="/ {print $2}' \
-				$buildfile | grep "^$cur" )
-			    $( awk -F"'" "/<target name='/ "'{print $2}' \
-				$buildfile | grep "^$cur" )
-			    $( awk -F'"' '/<target [^n]/ {if ($1 ~ /name=/) { print $2 } else if ($3 ~ /name=/) {print $4} else if ($5 ~ /name=/) {print $6}}' \
-				$buildfile | grep "^$cur" ) )
+		# some versions of sed complain if there's no trailing linefeed,
+		# hence the 2>/dev/null
+		COMPREPLY=( $( compgen -W "$( cat $buildfile | \
+			tr "'\t\n>" "\"  \n" | \
+			sed -ne 's/.*<target .*name="\([^"]*\).*/\1/p' \
+			2>/dev/null )" -- $cur ) )
 	fi
 }
 have complete-ant-cmd.pl && \

-- 
bash-completion



More information about the Bash-completion-commits mailing list