annotate install-sh @ 17:3cbd40805795 tip

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