From bcfb4569aa70f94711ee19630dbd76fecd8dffe7 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 3 Nov 2013 12:40:24 +0000 Subject: 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 --- win32/ifchange.bat | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'win32') 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% -- cgit v1.2.3