Update find-binary-for-platform to work with non-GNU versions of find

This commit is contained in:
Cecile Robert-Michon 2020-04-29 15:58:03 -07:00
parent 6c0278ed45
commit 7d6ba67da0
No known key found for this signature in database
GPG Key ID: D6291E8F62879D77

View File

@ -208,7 +208,12 @@ kube::util::find-binary-for-platform() {
locations+=("$location");
done < <(find "${KUBE_ROOT}/bazel-bin/" -type f -executable \
\( -path "*/${platform/\//_}*/${lookfor}" -o -path "*/${lookfor}" \) 2>/dev/null || true)
# search for executables for non-GNU versions of find (eg. BSD)
while IFS=$'\n' read -r location; do
locations+=("$location");
done < <(find "${KUBE_ROOT}/bazel-bin/" -type f -perm -111 \
\( -path "*/${platform/\//_}*/${lookfor}" -o -path "*/${lookfor}" \) 2>/dev/null || true)
# List most recently-updated location.
local -r bin=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 )
echo -n "${bin}"