summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-03 12:40:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-03 12:40:24 +0000
commitbcfb4569aa70f94711ee19630dbd76fecd8dffe7 (patch)
tree64edf1ca2513d74eb577ab3c9dec3ee83258221d /tool
parentddf1d3aaed4d07d8fb00f4c3a81b6a83bd0225e8 (diff)
ifchange: no overwrite with an empty file
* tool/ifchange, win32/ifchange.bat: do not overwrite with an empty file by default, and add --empty option to force it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rwxr-xr-xtool/ifchange6
1 files changed, 5 insertions, 1 deletions
diff --git a/tool/ifchange b/tool/ifchange
index 5695e5a9b8..488e9db26e 100755
--- a/tool/ifchange
+++ b/tool/ifchange
@@ -4,6 +4,7 @@
set -e
timestamp=
keepsuffix=
+empty=
until [ $# -eq 0 ]; do
case "$1" in
--timestamp)
@@ -18,6 +19,9 @@ until [ $# -eq 0 ]; do
--keep=*)
keepsuffix=`expr \( "$1" : '[^=]*=\(.*\)' \)`
;;
+ --empty)
+ empty=yes
+ ;;
*)
break
;;
@@ -33,7 +37,7 @@ if [ "$temp" = - ]; then
trap 'rm -f "$temp"' 0
fi
-if cmp "$target" "$temp" >/dev/null 2>&1; then
+if [ -f "$target" -a ! -${empty:+f}${empty:-s} "$temp" ] || cmp "$target" "$temp" >/dev/null 2>&1; then
echo "$target unchanged"
rm -f "$temp"
else