From: Eric Ball Date: Thu, 24 Oct 2019 23:32:51 +0000 (-0700) Subject: Use -o with grep to guarantee filename position X-Git-Tag: v0.46.0^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=4e319cf56e36d9f4221d0ea3dcb956d75fea4771;p=releng%2Fglobal-jjb.git Use -o with grep to guarantee filename position The "-o" option makes grep only return the matching words. This way, even if there are other params listed before -f, the filename will always be in position 2 of the grep output. Issue: RELENG-2428 Change-Id: Id52e3bf285de7f0e46d4a442ef4b0986d2e66cbc Signed-off-by: Eric Ball --- diff --git a/shell/maven-fetch-metadata.sh b/shell/maven-fetch-metadata.sh index 45f1a9b9..3c9b78f4 100644 --- a/shell/maven-fetch-metadata.sh +++ b/shell/maven-fetch-metadata.sh @@ -13,7 +13,7 @@ echo "---> maven-fetch-metadata.sh" # Check for "-f" maven param, indicating a change in pom location. pom_path="pom.xml" -file_path=$(echo "$MAVEN_PARAMS" | grep -E "\-f \S+" | awk '{ print $2 }') +file_path=$(echo "$MAVEN_PARAMS" | grep -Eo "\-f \S+" | awk '{ print $2 }') if [ -n "$file_path" ]; then if [ -d "$file_path" ]; then pom_path="$file_path/pom.xml"