Skip to content

Commit e1d46eb

Browse files
committed
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: #152
1 parent 89b03df commit e1d46eb

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/run.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,13 @@ make_xattrs() {
415415

416416
# Get the Unix epoch time in seconds
417417
epoch_time() {
418-
# https://stackoverflow.com/a/12746260/502399
419-
awk 'BEGIN { srand(); print srand(); }'
418+
if [ "${EPOCHSECONDS:-}" ]; then
419+
# Added in bash 5
420+
printf '%d' "$EPOCHSECONDS"
421+
else
422+
# https://stackoverflow.com/a/12746260/502399
423+
awk 'BEGIN { srand(); print srand(); }'
424+
fi
420425
}
421426

422427
## Snapshot testing

0 commit comments

Comments
 (0)