annotate install-sh @ 2596:04d381f0d89a tip

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