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