#!/usr/bin/env bash if [ x"$1" = x ] then # print help cat <&1 | tee "$OLD_FILE" # make the current version if [ ! -z "$(echo "$CHANGE" | grep "No local changes to save")" ]; then # there is no diff, so just copy the time file cp "$OLD_FILE" "$NEW_FILE" else # there is a diff, so restore the changes git stash pop # now if we're interrupted, we should only exit immediately, # not pop more stashes trap "exit 1" SIGHUP SIGINT SIGTERM # we must `make clean` so we have a fresh slate, and time # _all_ the files make clean # run the given `make` command, passing `TIMED=1` to get # timing and `-k` to continue even if files fail $MAKECMD TIMED=1 -k 2>&1 | tee "$NEW_FILE" fi else # if we're only making one state of the library, we still must # `make clean` so we have a fresh slate, and time _all_ the files make clean # run the given `make` command, passing `TIMED=1` to get timing # and `-k` to continue even if files fail $MAKECMD TIMED=1 -k 2>&1 | tee "$NEW_FILE" fi popd 1>/dev/null