From 66da469f0520b87fe0db696cd9314c0de50021e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Lhez?= Date: Wed, 26 Aug 2015 23:36:14 +0200 Subject: [PATCH] fix: sed + profile (continuation) --- bash_completion.bash | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bash_completion.bash b/bash_completion.bash index 5d79d76..fb94fce 100755 --- a/bash_completion.bash +++ b/bash_completion.bash @@ -187,24 +187,29 @@ _mvn() local plugin_goals_wildfly="wildfly:add-resource|wildfly:deploy|wildfly:deploy-only|wildfly:deploy-artifact|wildfly:redeploy|wildfly:redeploy-only|wildfly:undeploy|wildfly:undeploy-artifact|wildfly:run|wildfly:start|wildfly:shutdown|wildfly:execute-commands" ## some plugin (like jboss-as) has '-' which is not allowed in shell var name, to use '_' then replace - local common_plugins=`compgen -v | \grep "^plugin_goals_.*" | sed -e 's/plugin_goals_//g' -e 's/_/-/g' | tr '\n' '|'` + local common_plugins=`compgen -v | \grep "^plugin_goals_.*" | sed -e 's/plugin_goals_//g' -e 's/_/-/g' -e 's@\n@|@g'` 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 "" -A 1 ~/.m2/settings.xml | \grep -e ".*" | sed -e 's/.*//' -e 's/<\/id>.*//g' | tr '\n' '|' ` - + local OIFS=$IFS local IFS=$'|\n' if [[ ${cur} == -D* ]] ; then COMPREPLY=( $(compgen -S ' ' -W "${options}" -- ${cur}) ) elif [[ ${prev} == -P || ${prev} == --activate-profiles ]] ; then + IFS=$OIFS + + local profile_settings=`[ -e ~/.m2/settings.xml ] && \grep -e "" -A 1 ~/.m2/settings.xml | \grep -e ".*" | sed -e 's/.*//' -e 's/<\/id>.*//g' -e 's@\n@|@g' ` local profiles="${profile_settings}|" for item in ${POM_HIERARCHY[*]} do - local profile_pom=`[ -e $item ] && \grep -e "" -A 1 $item | \grep -e ".*" | sed -e 's/.*//' -e 's/<\/id>.*//g' | tr '\n' '|' ` + local profile_pom=`[ -e $item ] && \grep -e "" -A 1 $item | \grep -e ".*" | sed -e 's/.*//' -e 's/<\/id>.*//g' -e 's@\n@|@g' ` local profiles="${profiles}|${profile_pom}" done + + IFS=$'|\n' + if [[ ${cur} == *,* ]] ; then COMPREPLY=( $(compgen -S ',' -W "${profiles}" -P "${cur%,*}," -- ${cur##*,}) ) else