From 9492ff84fbf60874e297a079593385a436a91e72 Mon Sep 17 00:00:00 2001 From: Phil Jay Date: Tue, 1 Feb 2022 12:23:49 +1100 Subject: [PATCH] Avoid broken pipe exits (`141`) when `head` exits Intermittent issue, only observed on self-hosted agents on VMware (due to multi-core processing) --- version-lookup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version-lookup.sh b/version-lookup.sh index 0dd91e9..71b794a 100755 --- a/version-lookup.sh +++ b/version-lookup.sh @@ -34,11 +34,11 @@ fi ## Version parsing # detect current version - removing "v" from start of tag if it exists -current_version="$(git tag -l | { ${grep} -P "${pcre_allow_vprefix}" || true; } | sed 's/^v//g' | sort -V --reverse | head -n1)" +current_version="$(git tag -l | { ${grep} -P "${pcre_allow_vprefix}" || true; } | sed 's/^v//g' | sort -V | tail -n 1)" # support transition from an old reecetech calver style (yyyy-mm-Rr, where R is the literal `R`, and r is the nth release for the month) if [[ -z "${current_version:-}" ]] ; then - current_version="$(git tag -l | { ${grep} -P "${pcre_old_calver}" || true; } | sort -V --reverse | head -n1)" + current_version="$(git tag -l | { ${grep} -P "${pcre_old_calver}" || true; } | sort -V | tail -n 1)" if [[ -n "${current_version:-}" ]] ; then # convert - to . and drop leading zeros & the R current_version="$(echo "${current_version}" | sed -r 's/^([0-9]+)-0{0,1}([0-9]+)-R0{0,1}([0-9]+)$/\1.\2.\3/')"