annotate install-sh @ 1023:1f62a890da58

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