We have systems that start off with inaccurate clocks and at some point after the boot process synchronize with the network and jump forward in time. This has the potential to break any scripts that are sitting in loops, calculating a timeout based on the $SECONDS variable. The current behavior using realtime instead of monotime is surprising to us.
It would be nice if $SECONDS was using `clock_gettime(CLOCK_MONOTONIC, &val)` as it would usually make the most sense when you want to know the time since the script started. I understand changing this now may have undesirable consequences for those who are using $SECONDS arounds suspends in their scripts on personal machines. Maybe the correct proposal would be to add a mechanism for querying the monotonic time? I know I can write a pure bash function to look at /proc/uptime, but I think it would be nicer to have some builtin that is able to read the monotonic timer in a single syscall. ``` get_mono_ms() { local v="$(</proc/uptime)" v="${v%% *}" printf '%d%d0\n' "${v%%.*}" "${v##*.}" } ```