--- /dev/null
+#! /bin/sh
+
+set -e
+case "$#:$1" in
+ 0:* | 1:-h | 1:--help)
+ echo "$0 FILE PROG ARGS"
+ echo " Run PROG with ARGS, writing its stdout to FILE if it succeeds."
+ echo " Clobbers FILE.new."
+ exit 0
+ ;;
+ 1:*)
+ echo >&2 "$0 FILE PROG ARGS"
+ exit 1
+ ;;
+esac
+file=$1; shift
+set +e; "$@" >"$file.new"; st=$?; set -e
+if [ $st -eq 0 ]; then
+ mv "$file.new" "$file"
+else
+ rm "$file.new"
+fi
+exit $st