1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool/ifchange

18 lines
335 B
Text
Raw Normal View History

#!/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"
rm -f "$temp"
else
echo "$target updated"
mv -f "$temp" "$target"
fi