summaryrefslogtreecommitdiff
path: root/tool/ifchange
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-16 03:30:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-16 03:30:01 +0000
commit2bb561ea5f96f8b6edd622be16be89ee6af3cd7e (patch)
tree28a8858a3698a70a24b559fc46b52bb1d212f440 /tool/ifchange
parent40819d4599203e324cab5c6beea33cfb09a6ddfc (diff)
* common.mk (REVISION_H): keeps timestamp of revision.h.
[ruby-core:22900] * tool/ifchange, win32/ifchange.bat: extended --timestamp option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/ifchange')
-rwxr-xr-xtool/ifchange36
1 files changed, 30 insertions, 6 deletions
diff --git a/tool/ifchange b/tool/ifchange
index 8bfca26..ca2ea40 100755
--- a/tool/ifchange
+++ b/tool/ifchange
@@ -1,11 +1,22 @@
#!/bin/sh
# usage: ifchange target temporary
-unset timestamp
-if [ "$1" = --timestamp ]; then
- timestamp=yes
+timestamp=
+until [ "$0" = 0 ]; do
+ case "$1" in
+ --timestamp)
+ timestamp=.
+ ;;
+ --timestamp=*)
+ timestamp="${1#*=}" || timestamp=`expr "$1" : '[^=]*=\(.*\)'`
+ ;;
+ *)
+ break
+ ;;
+ esac
shift
-fi
+done
+
target="$1"
temp="$2"
if [ "$temp" = - ]; then
@@ -13,6 +24,7 @@ if [ "$temp" = - ]; then
cat > "$temp" || exit $?
trap 'rm -f "$temp"' 0
fi
+
if cmp "$target" "$temp" >/dev/null 2>&1; then
echo "$target unchanged"
rm -f "$temp"
@@ -20,6 +32,18 @@ else
echo "$target updated"
mv -f "$temp" "$target"
fi
-if [ $timestamp ]; then
- touch `dirname "$target"`/.time.`basename "$target"`
+
+if [ -n "${timestamp}" ]; then
+ if [ x"${timestamp}" = x. ]; then
+ case "$target" in
+ */*)
+ timestamp="${target%/*}"/.time."${target##*/}" ||
+ timestamp=`dirname "$target"`/.time.`basename "$target"`
+ ;;
+ *)
+ timestamp=.time."$target"
+ ;;
+ esac
+ fi
+ : > "$timestamp"
fi