mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
b025ce4678
* tool/ifchange, win32/ifchange.bat: --timestamp option added. * tool/generic_erb.rb: --timestamp, --output and --if-change options added. * template/id.h.tmpl: moved from id.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
25 lines
498 B
Bash
Executable file
25 lines
498 B
Bash
Executable file
#!/bin/sh
|
|
# usage: ifchange target temporary
|
|
|
|
unset timestamp
|
|
if [ "$1" = --timestamp ]; then
|
|
timestamp=yes
|
|
shift
|
|
fi
|
|
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
|
|
if [ $timestamp ]; then
|
|
touch `dirname "$target"`/.time.`basename "$target"`
|
|
fi
|