summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtool/ifchange6
-rwxr-xr-xwin32/ifchange.bat14
2 files changed, 16 insertions, 4 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
diff --git a/win32/ifchange.bat b/win32/ifchange.bat
index 1444d1bc2f..ed10914953 100755
--- a/win32/ifchange.bat
+++ b/win32/ifchange.bat
@@ -3,6 +3,7 @@
set timestamp=
set keepsuffix=
+set empty=
:optloop
for %%I in (%1) do set opt=%%~I
if "%opt%" == "--timestamp" (
@@ -21,6 +22,10 @@ if "%opt%" == "--timestamp" (
set keepsuffix=%opt:~7%
shift
goto :optloop
+) else if "%opt%" == "--empty" (
+ set empty=yes
+ shift
+ goto :optloop
)
if "%opt%" == "" goto :end
@@ -66,15 +71,18 @@ del %2
goto :end
:nt
-if not exist %src% goto :end
if exist %dest% (
+ if not exist %src% goto :nt_unchanged1
+ if "%empty%" == "" for %%I in (%src%) do if %%~zI == 0 goto :nt_unchanged
fc.exe %dest% %src% > nul && (
- echo %1 unchanged.
+ :nt_unchanged
del %src%
+ :nt_unchanged1
+ for %%I in (%1) do echo %%~I unchanged
goto :nt_end
)
)
-echo %1 updated.
+for %%I in (%1) do echo %%~I updated
copy %src% %dest% > nul
del %src%