Skip to content

Commit 3e0d3de

Browse files
committed
fix: when grep is alias (like alias grep='grep --color -Hn'), completions fails;
also, don't invoke sed twice, when one time can be done (sed -e .. -e .. ...)
1 parent 63b6bd1 commit 3e0d3de

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

bash_completion.bash

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ __pom_hierarchy()
9292
{
9393
local pom=`_realpath "pom.xml"`
9494
POM_HIERARCHY+=("$pom")
95-
while [ -n "$pom" ] && grep -q "<parent>" "$pom"; do
95+
while [ -n "$pom" ] && \grep -q "<parent>" "$pom"; do
9696
## look for a new relativePath for parent pom.xml
97-
local parent_pom_relative=`grep -e "<relativePath>.*</relativePath>" "$pom" | sed 's/.*<relativePath>//' | sed 's/<\/relativePath>.*//g'`
97+
local parent_pom_relative=`\grep -e "<relativePath>.*</relativePath>" "$pom" | sed -e 's/.*<relativePath>//' -e 's/<\/relativePath>.*//g'`
9898

9999
## <parent> is present but not defined, assume ../pom.xml
100100
if [ -z "$parent_pom_relative" ]; then
@@ -103,7 +103,7 @@ __pom_hierarchy()
103103

104104
## if pom exists continue else break
105105
parent_pom=`_realpath "${pom%/*}/$parent_pom_relative"`
106-
if [ -n "$parent_pom" ]; then
106+
if [ -n "$parent_pom" ]; then
107107
pom=$parent_pom
108108
else
109109
break
@@ -187,16 +187,16 @@ _mvn()
187187
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"
188188

189189
## some plugin (like jboss-as) has '-' which is not allowed in shell var name, to use '_' then replace
190-
local common_plugins=`compgen -v | grep "^plugin_goals_.*" | sed 's/plugin_goals_//g' | tr '_' '-' | tr '\n' '|'`
190+
local common_plugins=`compgen -v | \grep "^plugin_goals_.*" | sed -e 's/plugin_goals_//g' -e 's/_/-/g' | tr '\n' '|'`
191191

192192
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"
193193

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

196196
local profiles="${profile_settings}|"
197197
for item in ${POM_HIERARCHY[*]}
198198
do
199-
local profile_pom=`[ -e $item ] && grep -e "<profile>" -A 1 $item | grep -e "<id>.*</id>" | sed 's/.*<id>//' | sed 's/<\/id>.*//g' | tr '\n' '|' `
199+
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' '|' `
200200
local profiles="${profiles}|${profile_pom}"
201201
done
202202

@@ -239,9 +239,9 @@ _mvn()
239239
done
240240

241241
else
242-
if echo "${common_lifecycle_phases}" | tr '|' '\n' | grep -q -e "^${cur}" ; then
242+
if echo "${common_lifecycle_phases}" | tr '|' '\n' | \grep -q -e "^${cur}" ; then
243243
COMPREPLY=( $(compgen -S ' ' -W "${common_lifecycle_phases}" -- ${cur}) )
244-
elif echo "${common_plugins}" | tr '|' '\n' | grep -q -e "^${cur}"; then
244+
elif echo "${common_plugins}" | tr '|' '\n' | \grep -q -e "^${cur}"; then
245245
COMPREPLY=( $(compgen -S ':' -W "${common_plugins}" -- ${cur}) )
246246
fi
247247
fi

0 commit comments

Comments
 (0)