#!/bin/bash src="${1?Missing source document}" path="${2?Missing spec src path}" domake() { pdflatex -draftmode "$src" >&2 } gendate() { echo -n "$( git log -n1 --pretty=format:%ai | cut -d' ' -f1 ) " } domake \ && echo -n 'id ' \ && head -n1 taskstats.dat \ && \ ( echo -n '0 ' && gendate && tail -n1 taskstats.dat \ && git log --no-merges --pretty=format:'%at %h' -- "$path" \ | awk ' BEGIN { last=0 now=systime() } { # calculate the number of days ago this was ago = int( ( now - $1 ) / 86400 ); if ( ago <= last ) next; last = ago; print ago, $NF; } ' \ | while read n h; do git checkout "$h" >&2 \ && domake \ && echo -n "-$n " \ && gendate \ && tail -n1 taskstats.dat \ || { echo "Aborting data gathering."; exit 1; } done )