From f108ed7d9fadf0e633343e00b4e1d7b576e630e1 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 13 Mar 2023 10:20:03 -0300 Subject: {git-post-receive,cronjob}.sh: Improve portability - don't use GNU's date(1) "%s" proprietary option, and leverage AWK's default behaviour of `srand()` to get the seconds since UNIX epoch; - don't rely on GNU's sed(1) "-u" proprietary option of unbuffering, and do a manual `while` loop instead. --- src/infrastructure/ci/git-post-receive.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/infrastructure/ci/git-post-receive.sh') diff --git a/src/infrastructure/ci/git-post-receive.sh b/src/infrastructure/ci/git-post-receive.sh index 68d4da2..ab8c9d5 100755 --- a/src/infrastructure/ci/git-post-receive.sh +++ b/src/infrastructure/ci/git-post-receive.sh @@ -33,6 +33,10 @@ for n in $(seq 0 $((GIT_PUSH_OPTION_COUNT - 1))); do done +epoch() { + awk 'BEGIN { srand(); print(srand()); }' +} + now() { date '+%Y-%m-%dT%H:%M:%S%:z' } @@ -82,7 +86,7 @@ mkdtemp() { cat <<-EOF | info Starting CI job at: $(now) EOF - START="$(date +%s)" + START="$(epoch)" duration() { if [ "$RUN_DURATION" -gt 60 ]; then @@ -98,7 +102,7 @@ mkdtemp() { finish() { STATUS="$?" - END="$(date +%s)" + END="$(epoch)" RUN_DURATION=$((END - START)) cat <<-EOF | info Finishing CI job at: $(now) -- cgit v1.2.3