mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
262529fdfb
* tool/ifchange (--keep=suffix): new option for debug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
56 lines
971 B
Bash
Executable file
56 lines
971 B
Bash
Executable file
#!/bin/sh
|
|
# usage: ifchange target temporary
|
|
|
|
timestamp=
|
|
keepsuffix=
|
|
until [ "$0" = 0 ]; do
|
|
case "$1" in
|
|
--timestamp)
|
|
timestamp=.
|
|
;;
|
|
--timestamp=*)
|
|
timestamp=`expr \( "$1" : '[^=]*=\(.*\)' \)`
|
|
;;
|
|
--keep)
|
|
keepsuffix=.old
|
|
;;
|
|
--keep=*)
|
|
keepsuffix=`expr \( "$1" : '[^=]*=\(.*\)' \)`
|
|
;;
|
|
*)
|
|
break
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
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"
|
|
${keepsuffix:+ mv -f "$target" "${target}${keepsuffix}" }
|
|
mv -f "$temp" "$target"
|
|
fi
|
|
|
|
if [ -n "${timestamp}" ]; then
|
|
if [ x"${timestamp}" = x. ]; then
|
|
case "$target" in
|
|
*/*)
|
|
timestamp=`dirname "$target"`/.time.`basename "$target"`
|
|
;;
|
|
*)
|
|
timestamp=.time."$target"
|
|
;;
|
|
esac
|
|
fi
|
|
: > "$timestamp"
|
|
fi
|