#!/usr/bin/env bash if [ -z "$1" -o -z "$2" -o -z "$3" ] 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 # 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