diff --git a/completions/ant b/completions/ant index 79970daf..80f8de68 100644 --- a/completions/ant +++ b/completions/ant @@ -50,11 +50,13 @@ _ant() [ ! -f $buildfile ] && return 0 # parse buildfile for targets - # some versions of sed complain if there's no trailing linefeed, - # hence the 2>/dev/null - COMPREPLY=( $( compgen -W "$( tr "'\t\n>" "\" \n" < $buildfile | \ - sed -ne 's/.*<\(target\|extension-point\) .*name="\([^"]*\).*/\2/p' 2>/dev/null )" \ - -- "$cur" ) ) + local line targets + while read -rd '>' line; do + [[ $line =~ \ + \<(targe|extension-poin)t[[:space:]].*name=[\"\']([^\"\']+) ]] \ + && targets+=" ${BASH_REMATCH[2]}" + done < $buildfile + COMPREPLY=( $( compgen -W '$targets' -- "$cur" ) ) fi } && have ant && { have complete-ant-cmd.pl && \ diff --git a/test/fixtures/ant/build.xml b/test/fixtures/ant/build.xml new file mode 100644 index 00000000..146c7f3b --- /dev/null +++ b/test/fixtures/ant/build.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/test/lib/completions/ant.exp b/test/lib/completions/ant.exp index de57f24a..a5f022ac 100644 --- a/test/lib/completions/ant.exp +++ b/test/lib/completions/ant.exp @@ -4,7 +4,10 @@ proc setup {} { proc teardown {} { - assert_env_unmodified + assert_env_unmodified { + /OLDPWD=/d + /BASH_REMATCH=/d + } } @@ -12,8 +15,10 @@ setup assert_complete_any "ant -" +sync_after_int +assert_complete_dir "bashcomp clean init realclean" "ant " $::srcdir/fixtures/ant sync_after_int