From 019c7fa57ab9526124503c0894a01e3e0ea8b005 Mon Sep 17 00:00:00 2001 From: David Cooper Date: Tue, 7 Dec 2021 10:29:54 -0500 Subject: [PATCH] Simplify extracting Git information testssl.sh currently calls "git log --format='%h %ci' -1 2>/dev/null" three times. This commits changes testssl.sh to make this call just once and then use Bash string manipulation to extract the necessary information from the result. --- testssl.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/testssl.sh b/testssl.sh index 917fc2a..4316a1d 100755 --- a/testssl.sh +++ b/testssl.sh @@ -129,8 +129,9 @@ declare -r SWCONTACT="dirk aet testssl dot sh" SWURL="https://testssl.sh/" if git rev-parse --is-inside-work-tree &>/dev/null; then declare -r GIT_REL="$(git log --format='%h %ci' -1 2>/dev/null | awk '{ print $1" "$2" "$3 }')" - declare -r GIT_REL_SHORT="$(git log --format='%h %ci' -1 2>/dev/null | awk '{ print $1 }')" - declare -r REL_DATE="$(git log --format='%h %ci' -1 2>/dev/null | awk '{ print $2 }')" + declare -r GIT_REL_SHORT="${GIT_REL%% *}" + declare -r REL_DATE_TIME="${GIT_REL#* }" + declare -r REL_DATE="${REL_DATE_TIME% *}" fi declare -r PROG_NAME="$(basename "$0")" declare -r RUN_DIR="$(dirname "$0")"