diff --git a/completions/ant b/completions/ant index c0205503..7c14fe78 100644 --- a/completions/ant +++ b/completions/ant @@ -48,6 +48,15 @@ _ant() break fi done + if [[ $i -eq $cword ]]; then + for i in $ANT_ARGS; do + if [[ $prev == -@(?(build)file|f) ]]; then + buildfile=$i + break + fi + prev=$i + done + fi [[ ! -f $buildfile ]] && return 0 # parse buildfile for targets diff --git a/test/lib/completions/ant.exp b/test/lib/completions/ant.exp index fa074598..12947243 100644 --- a/test/lib/completions/ant.exp +++ b/test/lib/completions/ant.exp @@ -6,6 +6,7 @@ proc setup {} { proc teardown {} { assert_env_unmodified { /OLDPWD=/d + /ANT_ARGS=/d } } @@ -25,4 +26,10 @@ assert_complete_dir "named-build" "ant -f named-build.xml " $::srcdir/fixtures/a sync_after_int +assert_bash_exec {OLD_ANT_ARGS=$ANT_ARGS; ANT_ARGS="-f named-build.xml"} +assert_complete_dir "named-build" "ant " $::srcdir/fixtures/ant "ant with buildfile from ANT_ARGS" +sync_after_int +assert_bash_exec {ANT_ARGS=$OLD_ANT_ARGS; unset -v OLD_ANT_ARGS} + + teardown