about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-09-02 09:17:32 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-09-02 09:17:32 +0000
commit16c84ec8ded6a2a64106b76d56db9bedb099148e (patch)
tree6317cdc88a2222d16e18ba8a67de3e46f23bdcdb /Completion
parenta4d443af4390a2669a71dd741643d6a0c03cfc3d (diff)
downloadzsh-16c84ec8ded6a2a64106b76d56db9bedb099148e.tar.gz
zsh-16c84ec8ded6a2a64106b76d56db9bedb099148e.tar.xz
zsh-16c84ec8ded6a2a64106b76d56db9bedb099148e.zip
21693: Jean-Baptiste Quenot: recursively find ant targets
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_ant18
1 files changed, 13 insertions, 5 deletions
diff --git a/Completion/Unix/Command/_ant b/Completion/Unix/Command/_ant
index 2c0e252d6..bf70915d7 100644
--- a/Completion/Unix/Command/_ant
+++ b/Completion/Unix/Command/_ant
@@ -6,6 +6,18 @@ local curcontext="$curcontext" state line expl ret=1
 typeset -A opt_args
 local buildfile classpath cp userjars importedfiles target='*:target:->target' targets tmp
 
+find_targets() {
+    importedfiles=( $(sed -n "s/ *<import[^>]* file=[\"']\([^\"']*\)[\"'].*/\1/p" < $1) )
+    targets=( $(sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $1) )
+    if (( $#importedfiles )) ; then
+	cd $1:h
+    	for file in $importedfiles ; do
+	    find_targets $file
+	done
+    fi
+    _wanted targets expl target compadd -a targets && ret=0
+}
+
 if [[ $service = *ANT_ARGS* ]]; then
   compset -q
   words=( fake "$words[@]" )
@@ -114,11 +126,7 @@ case $state in
         )//$'\015'}"
         _describe 'target' tmp && ret=0
       else
-        importedfiles=( $(sed -n "s/ *<import[^>]* file=[\"']\([^\"']*\)[\"'].*/\1/p" < $buildfile) )
-        targets=( $(sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $buildfile) )
-        (( $#importedfiles )) && targets+=( $(cd $buildfile:h;
-            sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $importedfiles) )
-        _wanted targets expl target compadd -a targets && ret=0
+        find_targets $buildfile
       fi
     else
       _message -e targets target