annotate install-sh @ 869:6c08e99ca0f3 tonioni

Merge from default branch
author Chris Cannam
date Mon, 10 Nov 2014 09:20:06 +0000
parents 7fb9b939722f
children
rev   line source
Chris@564 1 #!/bin/sh
Chris@564 2 # install - install a program, script, or datafile
Chris@564 3
Chris@564 4 scriptversion=2006-12-25.00
Chris@564 5
Chris@564 6 # This originates from X11R5 (mit/util/scripts/install.sh), which was
Chris@564 7 # later released in X11R6 (xc/config/util/install.sh) with the
Chris@564 8 # following copyright and license.
Chris@564 9 #
Chris@564 10 # Copyright (C) 1994 X Consortium
Chris@564 11 #
Chris@564 12 # Permission is hereby granted, free of charge, to any person obtaining a copy
Chris@564 13 # of this software and associated documentation files (the "Software"), to
Chris@564 14 # deal in the Software without restriction, including without limitation the
Chris@564 15 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
Chris@564 16 # sell copies of the Software, and to permit persons to whom the Software is
Chris@564 17 # furnished to do so, subject to the following conditions:
Chris@564 18 #
Chris@564 19 # The above copyright notice and this permission notice shall be included in
Chris@564 20 # all copies or substantial portions of the Software.
Chris@564 21 #
Chris@564 22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Chris@564 23 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Chris@564 24 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Chris@564 25 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
Chris@564 26 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
Chris@564 27 # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@564 28 #
Chris@564 29 # Except as contained in this notice, the name of the X Consortium shall not
Chris@564 30 # be used in advertising or otherwise to promote the sale, use or other deal-
Chris@564 31 # ings in this Software without prior written authorization from the X Consor-
Chris@564 32 # tium.
Chris@564 33 #
Chris@564 34 #
Chris@564 35 # FSF changes to this file are in the public domain.
Chris@564 36 #
Chris@564 37 # Calling this script install-sh is preferred over install.sh, to prevent
Chris@564 38 # `make' implicit rules from creating a file called install from it
Chris@564 39 # when there is no Makefile.
Chris@564 40 #
Chris@564 41 # This script is compatible with the BSD install script, but was written
Chris@564 42 # from scratch.
Chris@564 43
Chris@564 44 nl='
Chris@564 45 '
Chris@564 46 IFS=" "" $nl"
Chris@564 47
Chris@564 48 # set DOITPROG to echo to test this script
Chris@564 49
Chris@564 50 # Don't use :- since 4.3BSD and earlier shells don't like it.
Chris@564 51 doit=${DOITPROG-}
Chris@564 52 if test -z "$doit"; then
Chris@564 53 doit_exec=exec
Chris@564 54 else
Chris@564 55 doit_exec=$doit
Chris@564 56 fi
Chris@564 57
Chris@564 58 # Put in absolute file names if you don't have them in your path;
Chris@564 59 # or use environment vars.
Chris@564 60
Chris@564 61 chgrpprog=${CHGRPPROG-chgrp}
Chris@564 62 chmodprog=${CHMODPROG-chmod}
Chris@564 63 chownprog=${CHOWNPROG-chown}
Chris@564 64 cmpprog=${CMPPROG-cmp}
Chris@564 65 cpprog=${CPPROG-cp}
Chris@564 66 mkdirprog=${MKDIRPROG-mkdir}
Chris@564 67 mvprog=${MVPROG-mv}
Chris@564 68 rmprog=${RMPROG-rm}
Chris@564 69 stripprog=${STRIPPROG-strip}
Chris@564 70
Chris@564 71 posix_glob='?'
Chris@564 72 initialize_posix_glob='
Chris@564 73 test "$posix_glob" != "?" || {
Chris@564 74 if (set -f) 2>/dev/null; then
Chris@564 75 posix_glob=
Chris@564 76 else
Chris@564 77 posix_glob=:
Chris@564 78 fi
Chris@564 79 }
Chris@564 80 '
Chris@564 81
Chris@564 82 posix_mkdir=
Chris@564 83
Chris@564 84 # Desired mode of installed file.
Chris@564 85 mode=0755
Chris@564 86
Chris@564 87 chgrpcmd=
Chris@564 88 chmodcmd=$chmodprog
Chris@564 89 chowncmd=
Chris@564 90 mvcmd=$mvprog
Chris@564 91 rmcmd="$rmprog -f"
Chris@564 92 stripcmd=
Chris@564 93
Chris@564 94 src=
Chris@564 95 dst=
Chris@564 96 dir_arg=
Chris@564 97 dst_arg=
Chris@564 98
Chris@564 99 copy_on_change=false
Chris@564 100 no_target_directory=
Chris@564 101
Chris@564 102 usage="\
Chris@564 103 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
Chris@564 104 or: $0 [OPTION]... SRCFILES... DIRECTORY
Chris@564 105 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
Chris@564 106 or: $0 [OPTION]... -d DIRECTORIES...
Chris@564 107
Chris@564 108 In the 1st form, copy SRCFILE to DSTFILE.
Chris@564 109 In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
Chris@564 110 In the 4th, create DIRECTORIES.
Chris@564 111
Chris@564 112 Options:
Chris@564 113 --help display this help and exit.
Chris@564 114 --version display version info and exit.
Chris@564 115
Chris@564 116 -c (ignored)
Chris@564 117 -C install only if different (preserve the last data modification time)
Chris@564 118 -d create directories instead of installing files.
Chris@564 119 -g GROUP $chgrpprog installed files to GROUP.
Chris@564 120 -m MODE $chmodprog installed files to MODE.
Chris@564 121 -o USER $chownprog installed files to USER.
Chris@564 122 -s $stripprog installed files.
Chris@564 123 -t DIRECTORY install into DIRECTORY.
Chris@564 124 -T report an error if DSTFILE is a directory.
Chris@564 125
Chris@564 126 Environment variables override the default commands:
Chris@564 127 CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
Chris@564 128 RMPROG STRIPPROG
Chris@564 129 "
Chris@564 130
Chris@564 131 while test $# -ne 0; do
Chris@564 132 case $1 in
Chris@564 133 -c) ;;
Chris@564 134
Chris@564 135 -C) copy_on_change=true;;
Chris@564 136
Chris@564 137 -d) dir_arg=true;;
Chris@564 138
Chris@564 139 -g) chgrpcmd="$chgrpprog $2"
Chris@564 140 shift;;
Chris@564 141
Chris@564 142 --help) echo "$usage"; exit $?;;
Chris@564 143
Chris@564 144 -m) mode=$2
Chris@564 145 case $mode in
Chris@564 146 *' '* | *' '* | *'
Chris@564 147 '* | *'*'* | *'?'* | *'['*)
Chris@564 148 echo "$0: invalid mode: $mode" >&2
Chris@564 149 exit 1;;
Chris@564 150 esac
Chris@564 151 shift;;
Chris@564 152
Chris@564 153 -o) chowncmd="$chownprog $2"
Chris@564 154 shift;;
Chris@564 155
Chris@564 156 -s) stripcmd=$stripprog;;
Chris@564 157
Chris@564 158 -t) dst_arg=$2
Chris@564 159 shift;;
Chris@564 160
Chris@564 161 -T) no_target_directory=true;;
Chris@564 162
Chris@564 163 --version) echo "$0 $scriptversion"; exit $?;;
Chris@564 164
Chris@564 165 --) shift
Chris@564 166 break;;
Chris@564 167
Chris@564 168 -*) echo "$0: invalid option: $1" >&2
Chris@564 169 exit 1;;
Chris@564 170
Chris@564 171 *) break;;
Chris@564 172 esac
Chris@564 173 shift
Chris@564 174 done
Chris@564 175
Chris@564 176 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
Chris@564 177 # When -d is used, all remaining arguments are directories to create.
Chris@564 178 # When -t is used, the destination is already specified.
Chris@564 179 # Otherwise, the last argument is the destination. Remove it from $@.
Chris@564 180 for arg
Chris@564 181 do
Chris@564 182 if test -n "$dst_arg"; then
Chris@564 183 # $@ is not empty: it contains at least $arg.
Chris@564 184 set fnord "$@" "$dst_arg"
Chris@564 185 shift # fnord
Chris@564 186 fi
Chris@564 187 shift # arg
Chris@564 188 dst_arg=$arg
Chris@564 189 done
Chris@564 190 fi
Chris@564 191
Chris@564 192 if test $# -eq 0; then
Chris@564 193 if test -z "$dir_arg"; then
Chris@564 194 echo "$0: no input file specified." >&2
Chris@564 195 exit 1
Chris@564 196 fi
Chris@564 197 # It's OK to call `install-sh -d' without argument.
Chris@564 198 # This can happen when creating conditional directories.
Chris@564 199 exit 0
Chris@564 200 fi
Chris@564 201
Chris@564 202 if test -z "$dir_arg"; then
Chris@564 203 trap '(exit $?); exit' 1 2 13 15
Chris@564 204
Chris@564 205 # Set umask so as not to create temps with too-generous modes.
Chris@564 206 # However, 'strip' requires both read and write access to temps.
Chris@564 207 case $mode in
Chris@564 208 # Optimize common cases.
Chris@564 209 *644) cp_umask=133;;
Chris@564 210 *755) cp_umask=22;;
Chris@564 211
Chris@564 212 *[0-7])
Chris@564 213 if test -z "$stripcmd"; then
Chris@564 214 u_plus_rw=
Chris@564 215 else
Chris@564 216 u_plus_rw='% 200'
Chris@564 217 fi
Chris@564 218 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
Chris@564 219 *)
Chris@564 220 if test -z "$stripcmd"; then
Chris@564 221 u_plus_rw=
Chris@564 222 else
Chris@564 223 u_plus_rw=,u+rw
Chris@564 224 fi
Chris@564 225 cp_umask=$mode$u_plus_rw;;
Chris@564 226 esac
Chris@564 227 fi
Chris@564 228
Chris@564 229 for src
Chris@564 230 do
Chris@564 231 # Protect names starting with `-'.
Chris@564 232 case $src in
Chris@564 233 -*) src=./$src;;
Chris@564 234 esac
Chris@564 235
Chris@564 236 if test -n "$dir_arg"; then
Chris@564 237 dst=$src
Chris@564 238 dstdir=$dst
Chris@564 239 test -d "$dstdir"
Chris@564 240 dstdir_status=$?
Chris@564 241 else
Chris@564 242
Chris@564 243 # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
Chris@564 244 # might cause directories to be created, which would be especially bad
Chris@564 245 # if $src (and thus $dsttmp) contains '*'.
Chris@564 246 if test ! -f "$src" && test ! -d "$src"; then
Chris@564 247 echo "$0: $src does not exist." >&2
Chris@564 248 exit 1
Chris@564 249 fi
Chris@564 250
Chris@564 251 if test -z "$dst_arg"; then
Chris@564 252 echo "$0: no destination specified." >&2
Chris@564 253 exit 1
Chris@564 254 fi
Chris@564 255
Chris@564 256 dst=$dst_arg
Chris@564 257 # Protect names starting with `-'.
Chris@564 258 case $dst in
Chris@564 259 -*) dst=./$dst;;
Chris@564 260 esac
Chris@564 261
Chris@564 262 # If destination is a directory, append the input filename; won't work
Chris@564 263 # if double slashes aren't ignored.
Chris@564 264 if test -d "$dst"; then
Chris@564 265 if test -n "$no_target_directory"; then
Chris@564 266 echo "$0: $dst_arg: Is a directory" >&2
Chris@564 267 exit 1
Chris@564 268 fi
Chris@564 269 dstdir=$dst
Chris@564 270 dst=$dstdir/`basename "$src"`
Chris@564 271 dstdir_status=0
Chris@564 272 else
Chris@564 273 # Prefer dirname, but fall back on a substitute if dirname fails.
Chris@564 274 dstdir=`
Chris@564 275 (dirname "$dst") 2>/dev/null ||
Chris@564 276 expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
Chris@564 277 X"$dst" : 'X\(//\)[^/]' \| \
Chris@564 278 X"$dst" : 'X\(//\)$' \| \
Chris@564 279 X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
Chris@564 280 echo X"$dst" |
Chris@564 281 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
Chris@564 282 s//\1/
Chris@564 283 q
Chris@564 284 }
Chris@564 285 /^X\(\/\/\)[^/].*/{
Chris@564 286 s//\1/
Chris@564 287 q
Chris@564 288 }
Chris@564 289 /^X\(\/\/\)$/{
Chris@564 290 s//\1/
Chris@564 291 q
Chris@564 292 }
Chris@564 293 /^X\(\/\).*/{
Chris@564 294 s//\1/
Chris@564 295 q
Chris@564 296 }
Chris@564 297 s/.*/./; q'
Chris@564 298 `
Chris@564 299
Chris@564 300 test -d "$dstdir"
Chris@564 301 dstdir_status=$?
Chris@564 302 fi
Chris@564 303 fi
Chris@564 304
Chris@564 305 obsolete_mkdir_used=false
Chris@564 306
Chris@564 307 if test $dstdir_status != 0; then
Chris@564 308 case $posix_mkdir in
Chris@564 309 '')
Chris@564 310 # Create intermediate dirs using mode 755 as modified by the umask.
Chris@564 311 # This is like FreeBSD 'install' as of 1997-10-28.
Chris@564 312 umask=`umask`
Chris@564 313 case $stripcmd.$umask in
Chris@564 314 # Optimize common cases.
Chris@564 315 *[2367][2367]) mkdir_umask=$umask;;
Chris@564 316 .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
Chris@564 317
Chris@564 318 *[0-7])
Chris@564 319 mkdir_umask=`expr $umask + 22 \
Chris@564 320 - $umask % 100 % 40 + $umask % 20 \
Chris@564 321 - $umask % 10 % 4 + $umask % 2
Chris@564 322 `;;
Chris@564 323 *) mkdir_umask=$umask,go-w;;
Chris@564 324 esac
Chris@564 325
Chris@564 326 # With -d, create the new directory with the user-specified mode.
Chris@564 327 # Otherwise, rely on $mkdir_umask.
Chris@564 328 if test -n "$dir_arg"; then
Chris@564 329 mkdir_mode=-m$mode
Chris@564 330 else
Chris@564 331 mkdir_mode=
Chris@564 332 fi
Chris@564 333
Chris@564 334 posix_mkdir=false
Chris@564 335 case $umask in
Chris@564 336 *[123567][0-7][0-7])
Chris@564 337 # POSIX mkdir -p sets u+wx bits regardless of umask, which
Chris@564 338 # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
Chris@564 339 ;;
Chris@564 340 *)
Chris@564 341 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
Chris@564 342 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
Chris@564 343
Chris@564 344 if (umask $mkdir_umask &&
Chris@564 345 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
Chris@564 346 then
Chris@564 347 if test -z "$dir_arg" || {
Chris@564 348 # Check for POSIX incompatibilities with -m.
Chris@564 349 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
Chris@564 350 # other-writeable bit of parent directory when it shouldn't.
Chris@564 351 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
Chris@564 352 ls_ld_tmpdir=`ls -ld "$tmpdir"`
Chris@564 353 case $ls_ld_tmpdir in
Chris@564 354 d????-?r-*) different_mode=700;;
Chris@564 355 d????-?--*) different_mode=755;;
Chris@564 356 *) false;;
Chris@564 357 esac &&
Chris@564 358 $mkdirprog -m$different_mode -p -- "$tmpdir" && {
Chris@564 359 ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
Chris@564 360 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
Chris@564 361 }
Chris@564 362 }
Chris@564 363 then posix_mkdir=:
Chris@564 364 fi
Chris@564 365 rmdir "$tmpdir/d" "$tmpdir"
Chris@564 366 else
Chris@564 367 # Remove any dirs left behind by ancient mkdir implementations.
Chris@564 368 rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
Chris@564 369 fi
Chris@564 370 trap '' 0;;
Chris@564 371 esac;;
Chris@564 372 esac
Chris@564 373
Chris@564 374 if
Chris@564 375 $posix_mkdir && (
Chris@564 376 umask $mkdir_umask &&
Chris@564 377 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
Chris@564 378 )
Chris@564 379 then :
Chris@564 380 else
Chris@564 381
Chris@564 382 # The umask is ridiculous, or mkdir does not conform to POSIX,
Chris@564 383 # or it failed possibly due to a race condition. Create the
Chris@564 384 # directory the slow way, step by step, checking for races as we go.
Chris@564 385
Chris@564 386 case $dstdir in
Chris@564 387 /*) prefix='/';;
Chris@564 388 -*) prefix='./';;
Chris@564 389 *) prefix='';;
Chris@564 390 esac
Chris@564 391
Chris@564 392 eval "$initialize_posix_glob"
Chris@564 393
Chris@564 394 oIFS=$IFS
Chris@564 395 IFS=/
Chris@564 396 $posix_glob set -f
Chris@564 397 set fnord $dstdir
Chris@564 398 shift
Chris@564 399 $posix_glob set +f
Chris@564 400 IFS=$oIFS
Chris@564 401
Chris@564 402 prefixes=
Chris@564 403
Chris@564 404 for d
Chris@564 405 do
Chris@564 406 test -z "$d" && continue
Chris@564 407
Chris@564 408 prefix=$prefix$d
Chris@564 409 if test -d "$prefix"; then
Chris@564 410 prefixes=
Chris@564 411 else
Chris@564 412 if $posix_mkdir; then
Chris@564 413 (umask=$mkdir_umask &&
Chris@564 414 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
Chris@564 415 # Don't fail if two instances are running concurrently.
Chris@564 416 test -d "$prefix" || exit 1
Chris@564 417 else
Chris@564 418 case $prefix in
Chris@564 419 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
Chris@564 420 *) qprefix=$prefix;;
Chris@564 421 esac
Chris@564 422 prefixes="$prefixes '$qprefix'"
Chris@564 423 fi
Chris@564 424 fi
Chris@564 425 prefix=$prefix/
Chris@564 426 done
Chris@564 427
Chris@564 428 if test -n "$prefixes"; then
Chris@564 429 # Don't fail if two instances are running concurrently.
Chris@564 430 (umask $mkdir_umask &&
Chris@564 431 eval "\$doit_exec \$mkdirprog $prefixes") ||
Chris@564 432 test -d "$dstdir" || exit 1
Chris@564 433 obsolete_mkdir_used=true
Chris@564 434 fi
Chris@564 435 fi
Chris@564 436 fi
Chris@564 437
Chris@564 438 if test -n "$dir_arg"; then
Chris@564 439 { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
Chris@564 440 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
Chris@564 441 { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
Chris@564 442 test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
Chris@564 443 else
Chris@564 444
Chris@564 445 # Make a couple of temp file names in the proper directory.
Chris@564 446 dsttmp=$dstdir/_inst.$$_
Chris@564 447 rmtmp=$dstdir/_rm.$$_
Chris@564 448
Chris@564 449 # Trap to clean up those temp files at exit.
Chris@564 450 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
Chris@564 451
Chris@564 452 # Copy the file name to the temp name.
Chris@564 453 (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
Chris@564 454
Chris@564 455 # and set any options; do chmod last to preserve setuid bits.
Chris@564 456 #
Chris@564 457 # If any of these fail, we abort the whole thing. If we want to
Chris@564 458 # ignore errors from any of these, just make sure not to ignore
Chris@564 459 # errors from the above "$doit $cpprog $src $dsttmp" command.
Chris@564 460 #
Chris@564 461 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
Chris@564 462 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
Chris@564 463 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
Chris@564 464 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
Chris@564 465
Chris@564 466 # If -C, don't bother to copy if it wouldn't change the file.
Chris@564 467 if $copy_on_change &&
Chris@564 468 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
Chris@564 469 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
Chris@564 470
Chris@564 471 eval "$initialize_posix_glob" &&
Chris@564 472 $posix_glob set -f &&
Chris@564 473 set X $old && old=:$2:$4:$5:$6 &&
Chris@564 474 set X $new && new=:$2:$4:$5:$6 &&
Chris@564 475 $posix_glob set +f &&
Chris@564 476
Chris@564 477 test "$old" = "$new" &&
Chris@564 478 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
Chris@564 479 then
Chris@564 480 rm -f "$dsttmp"
Chris@564 481 else
Chris@564 482 # Rename the file to the real destination.
Chris@564 483 $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
Chris@564 484
Chris@564 485 # The rename failed, perhaps because mv can't rename something else
Chris@564 486 # to itself, or perhaps because mv is so ancient that it does not
Chris@564 487 # support -f.
Chris@564 488 {
Chris@564 489 # Now remove or move aside any old file at destination location.
Chris@564 490 # We try this two ways since rm can't unlink itself on some
Chris@564 491 # systems and the destination file might be busy for other
Chris@564 492 # reasons. In this case, the final cleanup might fail but the new
Chris@564 493 # file should still install successfully.
Chris@564 494 {
Chris@564 495 test ! -f "$dst" ||
Chris@564 496 $doit $rmcmd -f "$dst" 2>/dev/null ||
Chris@564 497 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
Chris@564 498 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
Chris@564 499 } ||
Chris@564 500 { echo "$0: cannot unlink or rename $dst" >&2
Chris@564 501 (exit 1); exit 1
Chris@564 502 }
Chris@564 503 } &&
Chris@564 504
Chris@564 505 # Now rename the file to the real destination.
Chris@564 506 $doit $mvcmd "$dsttmp" "$dst"
Chris@564 507 }
Chris@564 508 fi || exit 1
Chris@564 509
Chris@564 510 trap '' 0
Chris@564 511 fi
Chris@564 512 done
Chris@564 513
Chris@564 514 # Local variables:
Chris@564 515 # eval: (add-hook 'write-file-hooks 'time-stamp)
Chris@564 516 # time-stamp-start: "scriptversion="
Chris@564 517 # time-stamp-format: "%:y-%02m-%02d.%02H"
Chris@564 518 # time-stamp-end: "$"
Chris@564 519 # End: