From ce31c2c6786a879e39fae408f4be04e81031ce40 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 11 Aug 2021 10:04:39 -0700 Subject: [PATCH] Find (s)testr more reliably We have seen instances where type -p (s)testr seems to return with a leading blank line which confuses ansible later when trying to use the first line of output as the path to (s)testr. Address this by chomping with grep -v ^$. Additionally use type -P instead of -p to ensure we always get a path even when the command may be an alias or builtin. Change-Id: Ibffe1e1499eca18ef5dc3904fe222a55242b827d --- roles/fetch-subunit-output/files/find-testr.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/roles/fetch-subunit-output/files/find-testr.sh b/roles/fetch-subunit-output/files/find-testr.sh index bed451f05..3e5562d3f 100644 --- a/roles/fetch-subunit-output/files/find-testr.sh +++ b/roles/fetch-subunit-output/files/find-testr.sh @@ -62,7 +62,11 @@ if [[ -d .tox ]] ; then fi for command in $commands; do - found=$(type -p $command) + # Use -P instead of -p because we always want a path here even if + # there is an alias or builtin. We also filter blank lines as we + # only want lines with paths and in some cases type seems to produce + # blank lines. + found=$(type -P $command | grep -v ^$) if [[ -n $found ]] ; then echo $found break