install-sh revision 067610f1
1067610f1Smrg#!/bin/sh 2067610f1Smrg# install - install a program, script, or datafile 3067610f1Smrg 4067610f1Smrgscriptversion=2006-10-14.15 5067610f1Smrg 6067610f1Smrg# This originates from X11R5 (mit/util/scripts/install.sh), which was 7067610f1Smrg# later released in X11R6 (xc/config/util/install.sh) with the 8067610f1Smrg# following copyright and license. 9067610f1Smrg# 10067610f1Smrg# Copyright (C) 1994 X Consortium 11067610f1Smrg# 12067610f1Smrg# Permission is hereby granted, free of charge, to any person obtaining a copy 13067610f1Smrg# of this software and associated documentation files (the "Software"), to 14067610f1Smrg# deal in the Software without restriction, including without limitation the 15067610f1Smrg# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16067610f1Smrg# sell copies of the Software, and to permit persons to whom the Software is 17067610f1Smrg# furnished to do so, subject to the following conditions: 18067610f1Smrg# 19067610f1Smrg# The above copyright notice and this permission notice shall be included in 20067610f1Smrg# all copies or substantial portions of the Software. 21067610f1Smrg# 22067610f1Smrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23067610f1Smrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24067610f1Smrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25067610f1Smrg# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26067610f1Smrg# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27067610f1Smrg# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28067610f1Smrg# 29067610f1Smrg# Except as contained in this notice, the name of the X Consortium shall not 30067610f1Smrg# be used in advertising or otherwise to promote the sale, use or other deal- 31067610f1Smrg# ings in this Software without prior written authorization from the X Consor- 32067610f1Smrg# tium. 33067610f1Smrg# 34067610f1Smrg# 35067610f1Smrg# FSF changes to this file are in the public domain. 36067610f1Smrg# 37067610f1Smrg# Calling this script install-sh is preferred over install.sh, to prevent 38067610f1Smrg# `make' implicit rules from creating a file called install from it 39067610f1Smrg# when there is no Makefile. 40067610f1Smrg# 41067610f1Smrg# This script is compatible with the BSD install script, but was written 42067610f1Smrg# from scratch. 43067610f1Smrg 44067610f1Smrgnl=' 45067610f1Smrg' 46067610f1SmrgIFS=" "" $nl" 47067610f1Smrg 48067610f1Smrg# set DOITPROG to echo to test this script 49067610f1Smrg 50067610f1Smrg# Don't use :- since 4.3BSD and earlier shells don't like it. 51067610f1Smrgdoit="${DOITPROG-}" 52067610f1Smrgif test -z "$doit"; then 53067610f1Smrg doit_exec=exec 54067610f1Smrgelse 55067610f1Smrg doit_exec=$doit 56067610f1Smrgfi 57067610f1Smrg 58067610f1Smrg# Put in absolute file names if you don't have them in your path; 59067610f1Smrg# or use environment vars. 60067610f1Smrg 61067610f1Smrgmvprog="${MVPROG-mv}" 62067610f1Smrgcpprog="${CPPROG-cp}" 63067610f1Smrgchmodprog="${CHMODPROG-chmod}" 64067610f1Smrgchownprog="${CHOWNPROG-chown}" 65067610f1Smrgchgrpprog="${CHGRPPROG-chgrp}" 66067610f1Smrgstripprog="${STRIPPROG-strip}" 67067610f1Smrgrmprog="${RMPROG-rm}" 68067610f1Smrgmkdirprog="${MKDIRPROG-mkdir}" 69067610f1Smrg 70067610f1Smrgposix_glob= 71067610f1Smrgposix_mkdir= 72067610f1Smrg 73067610f1Smrg# Desired mode of installed file. 74067610f1Smrgmode=0755 75067610f1Smrg 76067610f1Smrgchmodcmd=$chmodprog 77067610f1Smrgchowncmd= 78067610f1Smrgchgrpcmd= 79067610f1Smrgstripcmd= 80067610f1Smrgrmcmd="$rmprog -f" 81067610f1Smrgmvcmd="$mvprog" 82067610f1Smrgsrc= 83067610f1Smrgdst= 84067610f1Smrgdir_arg= 85067610f1Smrgdstarg= 86067610f1Smrgno_target_directory= 87067610f1Smrg 88067610f1Smrgusage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 89067610f1Smrg or: $0 [OPTION]... SRCFILES... DIRECTORY 90067610f1Smrg or: $0 [OPTION]... -t DIRECTORY SRCFILES... 91067610f1Smrg or: $0 [OPTION]... -d DIRECTORIES... 92067610f1Smrg 93067610f1SmrgIn the 1st form, copy SRCFILE to DSTFILE. 94067610f1SmrgIn the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 95067610f1SmrgIn the 4th, create DIRECTORIES. 96067610f1Smrg 97067610f1SmrgOptions: 98067610f1Smrg-c (ignored) 99067610f1Smrg-d create directories instead of installing files. 100067610f1Smrg-g GROUP $chgrpprog installed files to GROUP. 101067610f1Smrg-m MODE $chmodprog installed files to MODE. 102067610f1Smrg-o USER $chownprog installed files to USER. 103067610f1Smrg-s $stripprog installed files. 104067610f1Smrg-t DIRECTORY install into DIRECTORY. 105067610f1Smrg-T report an error if DSTFILE is a directory. 106067610f1Smrg--help display this help and exit. 107067610f1Smrg--version display version info and exit. 108067610f1Smrg 109067610f1SmrgEnvironment variables override the default commands: 110067610f1Smrg CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG 111067610f1Smrg" 112067610f1Smrg 113067610f1Smrgwhile test $# -ne 0; do 114067610f1Smrg case $1 in 115067610f1Smrg -c) shift 116067610f1Smrg continue;; 117067610f1Smrg 118067610f1Smrg -d) dir_arg=true 119067610f1Smrg shift 120067610f1Smrg continue;; 121067610f1Smrg 122067610f1Smrg -g) chgrpcmd="$chgrpprog $2" 123067610f1Smrg shift 124067610f1Smrg shift 125067610f1Smrg continue;; 126067610f1Smrg 127067610f1Smrg --help) echo "$usage"; exit $?;; 128067610f1Smrg 129067610f1Smrg -m) mode=$2 130067610f1Smrg shift 131067610f1Smrg shift 132067610f1Smrg case $mode in 133067610f1Smrg *' '* | *' '* | *' 134067610f1Smrg'* | *'*'* | *'?'* | *'['*) 135067610f1Smrg echo "$0: invalid mode: $mode" >&2 136067610f1Smrg exit 1;; 137067610f1Smrg esac 138067610f1Smrg continue;; 139067610f1Smrg 140067610f1Smrg -o) chowncmd="$chownprog $2" 141067610f1Smrg shift 142067610f1Smrg shift 143067610f1Smrg continue;; 144067610f1Smrg 145067610f1Smrg -s) stripcmd=$stripprog 146067610f1Smrg shift 147067610f1Smrg continue;; 148067610f1Smrg 149067610f1Smrg -t) dstarg=$2 150067610f1Smrg shift 151067610f1Smrg shift 152067610f1Smrg continue;; 153067610f1Smrg 154067610f1Smrg -T) no_target_directory=true 155067610f1Smrg shift 156067610f1Smrg continue;; 157067610f1Smrg 158067610f1Smrg --version) echo "$0 $scriptversion"; exit $?;; 159067610f1Smrg 160067610f1Smrg --) shift 161067610f1Smrg break;; 162067610f1Smrg 163067610f1Smrg -*) echo "$0: invalid option: $1" >&2 164067610f1Smrg exit 1;; 165067610f1Smrg 166067610f1Smrg *) break;; 167067610f1Smrg esac 168067610f1Smrgdone 169067610f1Smrg 170067610f1Smrgif test $# -ne 0 && test -z "$dir_arg$dstarg"; then 171067610f1Smrg # When -d is used, all remaining arguments are directories to create. 172067610f1Smrg # When -t is used, the destination is already specified. 173067610f1Smrg # Otherwise, the last argument is the destination. Remove it from $@. 174067610f1Smrg for arg 175067610f1Smrg do 176067610f1Smrg if test -n "$dstarg"; then 177067610f1Smrg # $@ is not empty: it contains at least $arg. 178067610f1Smrg set fnord "$@" "$dstarg" 179067610f1Smrg shift # fnord 180067610f1Smrg fi 181067610f1Smrg shift # arg 182067610f1Smrg dstarg=$arg 183067610f1Smrg done 184067610f1Smrgfi 185067610f1Smrg 186067610f1Smrgif test $# -eq 0; then 187067610f1Smrg if test -z "$dir_arg"; then 188067610f1Smrg echo "$0: no input file specified." >&2 189067610f1Smrg exit 1 190067610f1Smrg fi 191067610f1Smrg # It's OK to call `install-sh -d' without argument. 192067610f1Smrg # This can happen when creating conditional directories. 193067610f1Smrg exit 0 194067610f1Smrgfi 195067610f1Smrg 196067610f1Smrgif test -z "$dir_arg"; then 197067610f1Smrg trap '(exit $?); exit' 1 2 13 15 198067610f1Smrg 199067610f1Smrg # Set umask so as not to create temps with too-generous modes. 200067610f1Smrg # However, 'strip' requires both read and write access to temps. 201067610f1Smrg case $mode in 202067610f1Smrg # Optimize common cases. 203067610f1Smrg *644) cp_umask=133;; 204067610f1Smrg *755) cp_umask=22;; 205067610f1Smrg 206067610f1Smrg *[0-7]) 207067610f1Smrg if test -z "$stripcmd"; then 208067610f1Smrg u_plus_rw= 209067610f1Smrg else 210067610f1Smrg u_plus_rw='% 200' 211067610f1Smrg fi 212067610f1Smrg cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 213067610f1Smrg *) 214067610f1Smrg if test -z "$stripcmd"; then 215067610f1Smrg u_plus_rw= 216067610f1Smrg else 217067610f1Smrg u_plus_rw=,u+rw 218067610f1Smrg fi 219067610f1Smrg cp_umask=$mode$u_plus_rw;; 220067610f1Smrg esac 221067610f1Smrgfi 222067610f1Smrg 223067610f1Smrgfor src 224067610f1Smrgdo 225067610f1Smrg # Protect names starting with `-'. 226067610f1Smrg case $src in 227067610f1Smrg -*) src=./$src ;; 228067610f1Smrg esac 229067610f1Smrg 230067610f1Smrg if test -n "$dir_arg"; then 231067610f1Smrg dst=$src 232067610f1Smrg dstdir=$dst 233067610f1Smrg test -d "$dstdir" 234067610f1Smrg dstdir_status=$? 235067610f1Smrg else 236067610f1Smrg 237067610f1Smrg # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 238067610f1Smrg # might cause directories to be created, which would be especially bad 239067610f1Smrg # if $src (and thus $dsttmp) contains '*'. 240067610f1Smrg if test ! -f "$src" && test ! -d "$src"; then 241067610f1Smrg echo "$0: $src does not exist." >&2 242067610f1Smrg exit 1 243067610f1Smrg fi 244067610f1Smrg 245067610f1Smrg if test -z "$dstarg"; then 246067610f1Smrg echo "$0: no destination specified." >&2 247067610f1Smrg exit 1 248067610f1Smrg fi 249067610f1Smrg 250067610f1Smrg dst=$dstarg 251067610f1Smrg # Protect names starting with `-'. 252067610f1Smrg case $dst in 253067610f1Smrg -*) dst=./$dst ;; 254067610f1Smrg esac 255067610f1Smrg 256067610f1Smrg # If destination is a directory, append the input filename; won't work 257067610f1Smrg # if double slashes aren't ignored. 258067610f1Smrg if test -d "$dst"; then 259067610f1Smrg if test -n "$no_target_directory"; then 260067610f1Smrg echo "$0: $dstarg: Is a directory" >&2 261067610f1Smrg exit 1 262067610f1Smrg fi 263067610f1Smrg dstdir=$dst 264067610f1Smrg dst=$dstdir/`basename "$src"` 265067610f1Smrg dstdir_status=0 266067610f1Smrg else 267067610f1Smrg # Prefer dirname, but fall back on a substitute if dirname fails. 268067610f1Smrg dstdir=` 269067610f1Smrg (dirname "$dst") 2>/dev/null || 270067610f1Smrg expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 271067610f1Smrg X"$dst" : 'X\(//\)[^/]' \| \ 272067610f1Smrg X"$dst" : 'X\(//\)$' \| \ 273067610f1Smrg X"$dst" : 'X\(/\)' \| . 2>/dev/null || 274067610f1Smrg echo X"$dst" | 275067610f1Smrg sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 276067610f1Smrg s//\1/ 277067610f1Smrg q 278067610f1Smrg } 279067610f1Smrg /^X\(\/\/\)[^/].*/{ 280067610f1Smrg s//\1/ 281067610f1Smrg q 282067610f1Smrg } 283067610f1Smrg /^X\(\/\/\)$/{ 284067610f1Smrg s//\1/ 285067610f1Smrg q 286067610f1Smrg } 287067610f1Smrg /^X\(\/\).*/{ 288067610f1Smrg s//\1/ 289067610f1Smrg q 290067610f1Smrg } 291067610f1Smrg s/.*/./; q' 292067610f1Smrg ` 293067610f1Smrg 294067610f1Smrg test -d "$dstdir" 295067610f1Smrg dstdir_status=$? 296067610f1Smrg fi 297067610f1Smrg fi 298067610f1Smrg 299067610f1Smrg obsolete_mkdir_used=false 300067610f1Smrg 301067610f1Smrg if test $dstdir_status != 0; then 302067610f1Smrg case $posix_mkdir in 303067610f1Smrg '') 304067610f1Smrg # Create intermediate dirs using mode 755 as modified by the umask. 305067610f1Smrg # This is like FreeBSD 'install' as of 1997-10-28. 306067610f1Smrg umask=`umask` 307067610f1Smrg case $stripcmd.$umask in 308067610f1Smrg # Optimize common cases. 309067610f1Smrg *[2367][2367]) mkdir_umask=$umask;; 310067610f1Smrg .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 311067610f1Smrg 312067610f1Smrg *[0-7]) 313067610f1Smrg mkdir_umask=`expr $umask + 22 \ 314067610f1Smrg - $umask % 100 % 40 + $umask % 20 \ 315067610f1Smrg - $umask % 10 % 4 + $umask % 2 316067610f1Smrg `;; 317067610f1Smrg *) mkdir_umask=$umask,go-w;; 318067610f1Smrg esac 319067610f1Smrg 320067610f1Smrg # With -d, create the new directory with the user-specified mode. 321067610f1Smrg # Otherwise, rely on $mkdir_umask. 322067610f1Smrg if test -n "$dir_arg"; then 323067610f1Smrg mkdir_mode=-m$mode 324067610f1Smrg else 325067610f1Smrg mkdir_mode= 326067610f1Smrg fi 327067610f1Smrg 328067610f1Smrg posix_mkdir=false 329067610f1Smrg case $umask in 330067610f1Smrg *[123567][0-7][0-7]) 331067610f1Smrg # POSIX mkdir -p sets u+wx bits regardless of umask, which 332067610f1Smrg # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 333067610f1Smrg ;; 334067610f1Smrg *) 335067610f1Smrg tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 336067610f1Smrg trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 337067610f1Smrg 338067610f1Smrg if (umask $mkdir_umask && 339067610f1Smrg exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 340067610f1Smrg then 341067610f1Smrg if test -z "$dir_arg" || { 342067610f1Smrg # Check for POSIX incompatibilities with -m. 343067610f1Smrg # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 344067610f1Smrg # other-writeable bit of parent directory when it shouldn't. 345067610f1Smrg # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 346067610f1Smrg ls_ld_tmpdir=`ls -ld "$tmpdir"` 347067610f1Smrg case $ls_ld_tmpdir in 348067610f1Smrg d????-?r-*) different_mode=700;; 349067610f1Smrg d????-?--*) different_mode=755;; 350067610f1Smrg *) false;; 351067610f1Smrg esac && 352067610f1Smrg $mkdirprog -m$different_mode -p -- "$tmpdir" && { 353067610f1Smrg ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 354067610f1Smrg test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 355067610f1Smrg } 356067610f1Smrg } 357067610f1Smrg then posix_mkdir=: 358067610f1Smrg fi 359067610f1Smrg rmdir "$tmpdir/d" "$tmpdir" 360067610f1Smrg else 361067610f1Smrg # Remove any dirs left behind by ancient mkdir implementations. 362067610f1Smrg rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 363067610f1Smrg fi 364067610f1Smrg trap '' 0;; 365067610f1Smrg esac;; 366067610f1Smrg esac 367067610f1Smrg 368067610f1Smrg if 369067610f1Smrg $posix_mkdir && ( 370067610f1Smrg umask $mkdir_umask && 371067610f1Smrg $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 372067610f1Smrg ) 373067610f1Smrg then : 374067610f1Smrg else 375067610f1Smrg 376067610f1Smrg # The umask is ridiculous, or mkdir does not conform to POSIX, 377067610f1Smrg # or it failed possibly due to a race condition. Create the 378067610f1Smrg # directory the slow way, step by step, checking for races as we go. 379067610f1Smrg 380067610f1Smrg case $dstdir in 381067610f1Smrg /*) prefix=/ ;; 382067610f1Smrg -*) prefix=./ ;; 383067610f1Smrg *) prefix= ;; 384067610f1Smrg esac 385067610f1Smrg 386067610f1Smrg case $posix_glob in 387067610f1Smrg '') 388067610f1Smrg if (set -f) 2>/dev/null; then 389067610f1Smrg posix_glob=true 390067610f1Smrg else 391067610f1Smrg posix_glob=false 392067610f1Smrg fi ;; 393067610f1Smrg esac 394067610f1Smrg 395067610f1Smrg oIFS=$IFS 396067610f1Smrg IFS=/ 397067610f1Smrg $posix_glob && set -f 398067610f1Smrg set fnord $dstdir 399067610f1Smrg shift 400067610f1Smrg $posix_glob && set +f 401067610f1Smrg IFS=$oIFS 402067610f1Smrg 403067610f1Smrg prefixes= 404067610f1Smrg 405067610f1Smrg for d 406067610f1Smrg do 407067610f1Smrg test -z "$d" && continue 408067610f1Smrg 409067610f1Smrg prefix=$prefix$d 410067610f1Smrg if test -d "$prefix"; then 411067610f1Smrg prefixes= 412067610f1Smrg else 413067610f1Smrg if $posix_mkdir; then 414067610f1Smrg (umask=$mkdir_umask && 415067610f1Smrg $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 416067610f1Smrg # Don't fail if two instances are running concurrently. 417067610f1Smrg test -d "$prefix" || exit 1 418067610f1Smrg else 419067610f1Smrg case $prefix in 420067610f1Smrg *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 421067610f1Smrg *) qprefix=$prefix;; 422067610f1Smrg esac 423067610f1Smrg prefixes="$prefixes '$qprefix'" 424067610f1Smrg fi 425067610f1Smrg fi 426067610f1Smrg prefix=$prefix/ 427067610f1Smrg done 428067610f1Smrg 429067610f1Smrg if test -n "$prefixes"; then 430067610f1Smrg # Don't fail if two instances are running concurrently. 431067610f1Smrg (umask $mkdir_umask && 432067610f1Smrg eval "\$doit_exec \$mkdirprog $prefixes") || 433067610f1Smrg test -d "$dstdir" || exit 1 434067610f1Smrg obsolete_mkdir_used=true 435067610f1Smrg fi 436067610f1Smrg fi 437067610f1Smrg fi 438067610f1Smrg 439067610f1Smrg if test -n "$dir_arg"; then 440067610f1Smrg { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 441067610f1Smrg { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 442067610f1Smrg { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 443067610f1Smrg test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 444067610f1Smrg else 445067610f1Smrg 446067610f1Smrg # Make a couple of temp file names in the proper directory. 447067610f1Smrg dsttmp=$dstdir/_inst.$$_ 448067610f1Smrg rmtmp=$dstdir/_rm.$$_ 449067610f1Smrg 450067610f1Smrg # Trap to clean up those temp files at exit. 451067610f1Smrg trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 452067610f1Smrg 453067610f1Smrg # Copy the file name to the temp name. 454067610f1Smrg (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 455067610f1Smrg 456067610f1Smrg # and set any options; do chmod last to preserve setuid bits. 457067610f1Smrg # 458067610f1Smrg # If any of these fail, we abort the whole thing. If we want to 459067610f1Smrg # ignore errors from any of these, just make sure not to ignore 460067610f1Smrg # errors from the above "$doit $cpprog $src $dsttmp" command. 461067610f1Smrg # 462067610f1Smrg { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ 463067610f1Smrg && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ 464067610f1Smrg && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ 465067610f1Smrg && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 466067610f1Smrg 467067610f1Smrg # Now rename the file to the real destination. 468067610f1Smrg { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \ 469067610f1Smrg || { 470067610f1Smrg # The rename failed, perhaps because mv can't rename something else 471067610f1Smrg # to itself, or perhaps because mv is so ancient that it does not 472067610f1Smrg # support -f. 473067610f1Smrg 474067610f1Smrg # Now remove or move aside any old file at destination location. 475067610f1Smrg # We try this two ways since rm can't unlink itself on some 476067610f1Smrg # systems and the destination file might be busy for other 477067610f1Smrg # reasons. In this case, the final cleanup might fail but the new 478067610f1Smrg # file should still install successfully. 479067610f1Smrg { 480067610f1Smrg if test -f "$dst"; then 481067610f1Smrg $doit $rmcmd -f "$dst" 2>/dev/null \ 482067610f1Smrg || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \ 483067610f1Smrg && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\ 484067610f1Smrg || { 485067610f1Smrg echo "$0: cannot unlink or rename $dst" >&2 486067610f1Smrg (exit 1); exit 1 487067610f1Smrg } 488067610f1Smrg else 489067610f1Smrg : 490067610f1Smrg fi 491067610f1Smrg } && 492067610f1Smrg 493067610f1Smrg # Now rename the file to the real destination. 494067610f1Smrg $doit $mvcmd "$dsttmp" "$dst" 495067610f1Smrg } 496067610f1Smrg } || exit 1 497067610f1Smrg 498067610f1Smrg trap '' 0 499067610f1Smrg fi 500067610f1Smrgdone 501067610f1Smrg 502067610f1Smrg# Local variables: 503067610f1Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 504067610f1Smrg# time-stamp-start: "scriptversion=" 505067610f1Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 506067610f1Smrg# time-stamp-end: "$" 507067610f1Smrg# End: 508