summaryrefslogtreecommitdiffstats
path: root/tests/run.sh
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2025-02-07 12:16:52 -0500
committerTavian Barnes <tavianator@tavianator.com>2025-02-07 12:16:52 -0500
commite1d46eb3da4cc6d04c93b4f4c1485a64887ac190 (patch)
tree8f3f0dcb902bbab6f1f26d8fa8fee494b88a11d8 /tests/run.sh
parent89b03df4f3bd19f9dc717dfc1c03e81d213e4d3d (diff)
downloadbfs-e1d46eb3da4cc6d04c93b4f4c1485a64887ac190.tar.xz
tests: Use $EPOCHSECONDS if it exists
Bash 5 adds that special variable, which should be more reliable than the awk trick, which is known to be broken on mawk. Fixes: https://github.com/tavianator/bfs/issues/152
Diffstat (limited to 'tests/run.sh')
-rw-r--r--tests/run.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/run.sh b/tests/run.sh
index 164790e..e3a4e3f 100644
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -415,8 +415,13 @@ make_xattrs() {
# Get the Unix epoch time in seconds
epoch_time() {
- # https://stackoverflow.com/a/12746260/502399
- awk 'BEGIN { srand(); print srand(); }'
+ if [ "${EPOCHSECONDS:-}" ]; then
+ # Added in bash 5
+ printf '%d' "$EPOCHSECONDS"
+ else
+ # https://stackoverflow.com/a/12746260/502399
+ awk 'BEGIN { srand(); print srand(); }'
+ fi
}
## Snapshot testing