summaryrefslogtreecommitdiff
path: root/win32/ifchange.bat
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-03 12:40:24 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-03 12:40:24 (GMT)
commitbcfb4569aa70f94711ee19630dbd76fecd8dffe7 (patch)
tree64edf1ca2513d74eb577ab3c9dec3ee83258221d /win32/ifchange.bat
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 'win32/ifchange.bat')
-rwxr-xr-xwin32/ifchange.bat14
1 files changed, 11 insertions, 3 deletions
diff --git a/win32/ifchange.bat b/win32/ifchange.bat
index 1444d1b..ed10914 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%