Skip to content

Commit

Permalink
fix: don't build the profile list if "-P" is not invoked before
Browse files Browse the repository at this point in the history
  • Loading branch information
glhez committed Jul 3, 2016
1 parent 2b89719 commit 36bd4f4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bash_completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,19 @@ _mvn()
local options="-Dmaven.test.skip=true|-DskipTests|-DskipITs|-Dtest|-Dit.test|-DfailIfNoTests|-Dmaven.surefire.debug|-DenableCiProfile|-Dpmd.skip=true|-Dcheckstyle.skip=true|-Dtycho.mode=maven|-Dmaven.javadoc.skip=true|-Dgwt.compiler.skip|-Dcobertura.skip=true|-Dfindbugs.skip=true||-DperformRelease=true|-Dgpg.skip=true|-DforkCount"

local profile_settings=`[ -e ~/.m2/settings.xml ] && \grep -e "<profile>" -A 1 ~/.m2/settings.xml | \grep -e "<id>.*</id>" | sed -e 's/.*<id>//' -e 's/<\/id>.*//g' | tr '\n' '|' `

local profiles="${profile_settings}|"
for item in ${POM_HIERARCHY[*]}
do
local profile_pom=`[ -e $item ] && \grep -e "<profile>" -A 1 $item | \grep -e "<id>.*</id>" | sed -e 's/.*<id>//' -e 's/<\/id>.*//g' | tr '\n' '|' `
local profiles="${profiles}|${profile_pom}"
done

local IFS=$'|\n'

if [[ ${cur} == -D* ]] ; then
COMPREPLY=( $(compgen -S ' ' -W "${options}" -- ${cur}) )

elif [[ ${prev} == -P ]] ; then
local profiles="${profile_settings}|"
for item in ${POM_HIERARCHY[*]}
do
local profile_pom=`[ -e $item ] && \grep -e "<profile>" -A 1 $item | \grep -e "<id>.*</id>" | sed -e 's/.*<id>//' -e 's/<\/id>.*//g' | tr '\n' '|' `
local profiles="${profiles}|${profile_pom}"
done
if [[ ${cur} == *,* ]] ; then
COMPREPLY=( $(compgen -S ',' -W "${profiles}" -P "${cur%,*}," -- ${cur##*,}) )
else
Expand Down

0 comments on commit 36bd4f4

Please sign in to comment.