diff --git a/tool/ifchange b/tool/ifchange new file mode 100755 index 0000000000..7a192643f9 --- /dev/null +++ b/tool/ifchange @@ -0,0 +1,16 @@ +#!/bin/sh +# usage: ifchange target temporary + +target="$1" +temp="$2" +if [ "$temp" = - ]; then + temp="tmpdata$$.tmp~" + cat > "$temp" || exit $? + trap 'rm -f "$temp"' 0 +fi +if cmp "$target" "$temp" >/dev/null 2>&1; then + echo "$target unchanged" +else + echo "$target updated" + mv -f "$temp" "$target" +fi