]> git.scottworley.com Git - keystroke-timestamps/commitdiff
Skip lines that are greater than 67767976233561595
authorScott Worley <scottworley@scottworley.com>
Sat, 31 May 2014 18:06:13 +0000 (11:06 -0700)
committerScott Worley <scottworley@scottworley.com>
Sat, 31 May 2014 18:06:13 +0000 (11:06 -0700)
Sometimes this happens if keystroke-timestamps is killed without
flushing, such as by SIGKILL or loss of power.  When this happens,
it can write a partial line.  When the next run starts up, it
appends a timestamp to the partial line, resulting in a timestamp
too large for awk to process.

GNU awk's end-of-time behavior:

$ f() { awk '{ print strftime("%F %T", $1) }' <<< "$1"; }

$ f 67767976233561595
2147483647-12-31 23:59:52
$ f 67767976233561596
-2147483648-01-01 00:00:00

$ f 67768036191705595
-2147481749-12-31 23:59:52
$ f 67768036191705596
awk: cmd. line:1: (FILENAME=- FNR=1) fatal error: internal error
Aborted

gaps.sh

diff --git a/gaps.sh b/gaps.sh
index 2d28af92a2cc6ba22d5fbb41325a2c28d546b8b0..361e2a61f12c764f1d6842bb50dd98d930836b3a 100755 (executable)
--- a/gaps.sh
+++ b/gaps.sh
@@ -4,7 +4,7 @@ threshold=${1:-3600}
 LOGFILE="${2:-$HOME/keystroke-timestamps.log}"
 
 awk -vthreshold="$threshold" -vtime_fmt="%F %T" '
-  {
+  $1 <= 67767976233561595 {
     if (prev && $1 - prev > threshold) {
       print(strftime(time_fmt, prev), "to", strftime(time_fmt, $1), "was", $1 - prev)
     }