diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2025-02-07 12:16:52 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2025-02-07 12:16:52 -0500 |
commit | e1d46eb3da4cc6d04c93b4f4c1485a64887ac190 (patch) | |
tree | 8f3f0dcb902bbab6f1f26d8fa8fee494b88a11d8 | |
parent | 89b03df4f3bd19f9dc717dfc1c03e81d213e4d3d (diff) | |
download | bfs-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
-rw-r--r-- | tests/run.sh | 9 |
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 |