Purpose: present how a file changes between before vs after a command.
Usage: dfdt file command [arg1 arg2 ...]
Runs command with arguments arg1, arg2, etc, expecting the command to modify file (not actually checked), and, after command finishes, shows a diff between the original form of file and its new form. The original file is kept in /tmp, and stays there for later access if you request it to be kept.
Changelog:
2022-264 initial development
2023-246 reformat/redocument a tad
Source code (perhaps slightly corrupted) is as follows.
WFN="$1"
shift
NFN=`mktemp`
cp "$WFN" "$NFN"
$*
diff "$NFN" "$WFN" | $PAGER
printf 'Keep old version ( %s )? ' "$NFN"
read KEEP
if [ "${KEEP#y}" = "$KEEP" ]
then
rm "$NFN"
fi