David Knupp has posted comments on this change. ( http://gerrit.cloudera.org:8080/9273 )
Change subject: IMPALA-5139: Update mvn-quiet.sh to print execution content to log file ...................................................................... Patch Set 5: (1 comment) http://gerrit.cloudera.org:8080/#/c/9273/5/bin/mvn-quiet.sh File bin/mvn-quiet.sh: http://gerrit.cloudera.org:8080/#/c/9273/5/bin/mvn-quiet.sh@35 PS5, Line 35: mvn "$@" | tee -a $LOG_FILE | grep -E -e WARNING -e ERROR -e SUCCESS -e FAILURE -e Test; then I'll repeat my caveat about not being any sort of bash expert. I recommend running my comments past someone else -- e.g., Phil Z. or Michael. I feel like there is something that is still confusing about this code, and some of it has to do with this patch, but a lot of it preceded your patch as well. * I still think mvn being piped to mvn is an odd construction, and probably something to be avoided * I think that the combined interaction between "set -eo pipefail" and the if-block and the piping is a little hard to reason about * I strongly suspect that inside the if-block, as it stands, "echo [...] exited with code $?" will *always* show an exit code of 0, regardless of whether mvn failed or not * That said, I do think that "exit 1" will execute if mvn failed, so at least the script will fail as expected Stepping back for a minute to consider what we want this script to do, I think it's something like this: * we don't want to see the verbose output of mvn, but we want to capture it in a log file * however, if there are lines ERRORS or WARNINGS or SUCCESS or FAILURE, we want to send those lines to the console * in the chain of mvn | tee | grep, we want to exit with a non-zero status if mvn fails, but we don't esepcially care about the exit status of tee and certainly not grep I think that all of those things can be accomplished with something like this. set -uo pipefail # i.e., get rid of set -e [...] mvn $IMPALA_MAVEN_OPTIONS "$@" | tee -a $LOG_FILE | \ grep -E -e WARNING -e ERROR -e SUCCESS -e FAILURE -e Test MVN_EXIT_STATUS=${PIPESTATUS[0]} echo "mvn exited with ${MVN_EXIT_STATUS}" exit ${MVN_EXIT_STATUS} Getting rid of "set -e" means that we can continue to execute in this script even if mvn fails, but without having to resort to "if mvn [...]; then...". Everything gets logged, but only lines matching our grep pattern go to console. mvn exit status is captured in ${PIPESTATUS[0]}, but tee and grep status are ignored. The script exits with the same status as mvn. This manages to avoid piping mvn to mvn. FYI, this is the page I read about to clarify my understanding of pipefail and PIPESTATUS: https://unix.stackexchange.com/questions/14270/get-exit-status-of-process-thats-piped-to-another -- To view, visit http://gerrit.cloudera.org:8080/9273 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I475b17a4dccfa624dda61402491b461c53473f8b Gerrit-Change-Number: 9273 Gerrit-PatchSet: 5 Gerrit-Owner: Nithya Janarthanan <njanartha...@cloudera.com> Gerrit-Reviewer: David Knupp <dkn...@cloudera.com> Gerrit-Reviewer: Michael Brown <mi...@cloudera.com> Gerrit-Reviewer: Philip Zeyliger <phi...@cloudera.com> Gerrit-Comment-Date: Thu, 15 Feb 2018 04:59:06 +0000 Gerrit-HasComments: Yes