summaryrefslogtreecommitdiffstats
path: root/src/main.sh
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-04-11 18:41:08 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-04-11 18:41:08 (EDT)
commit2a28f9f1332c06ecde12460d8bc49574e8323c59 (patch)
tree3c2281d286d7f462709fbd849a3a29a47ed6f715 /src/main.sh
parentd643f7726b47ee1ea4913811ac5a72bab2a22830 (diff)
main(): Replace non-portable expr and date %s spec
Diffstat (limited to 'src/main.sh')
-rw-r--r--src/main.sh20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main.sh b/src/main.sh
index d64de0e..054363d 100644
--- a/src/main.sh
+++ b/src/main.sh
@@ -34,6 +34,24 @@ else
builddir=''
fi
+time()
+{
+ # Based on code from <https://www.etalabs.net/sh_tricks.html> by Rich
+ # Felker, with whitespace added for readability.
+ printf '%d' $(($(TZ=UTC0 date "+
+ (
+ (%Y - 1600) * 365
+ + (%Y - 1600) / 4
+ - (%Y - 1600) / 100
+ + (%Y - 1600) / 400
+ + 1%j - 1000
+ - 135140
+ ) * 86400
+ + (1%H - 100) * 3600
+ + (1%M - 100) * 60
+ + (1%S - 100)")))
+}
+
main()
{
local cmd=
@@ -61,7 +79,7 @@ main()
shift
fi
- srand $(expr ${$} + $(date '+%s'))
+ srand $((${$} + $(time)))
if ! init_vardata; then
return 2
fi