mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
ddf1d3aaed
commit
bcfb4569aa
2 changed files with 16 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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%
|
||||
|
||||
|
|
Loading…
Reference in a new issue