1290001Sglebius#!/bin/sh 2290001Sglebius# install - install a program, script, or datafile 3290001Sglebius 4290001Sglebiusscriptversion=2009-04-28.21; # UTC 5290001Sglebius 6290001Sglebius# This originates from X11R5 (mit/util/scripts/install.sh), which was 7290001Sglebius# later released in X11R6 (xc/config/util/install.sh) with the 8290001Sglebius# following copyright and license. 9290001Sglebius# 10290001Sglebius# Copyright (C) 1994 X Consortium 11290001Sglebius# 12290001Sglebius# Permission is hereby granted, free of charge, to any person obtaining a copy 13290001Sglebius# of this software and associated documentation files (the "Software"), to 14290001Sglebius# deal in the Software without restriction, including without limitation the 15290001Sglebius# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16290001Sglebius# sell copies of the Software, and to permit persons to whom the Software is 17290001Sglebius# furnished to do so, subject to the following conditions: 18290001Sglebius# 19290001Sglebius# The above copyright notice and this permission notice shall be included in 20290001Sglebius# all copies or substantial portions of the Software. 21290001Sglebius# 22290001Sglebius# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23290001Sglebius# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24290001Sglebius# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25290001Sglebius# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26290001Sglebius# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27290001Sglebius# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28290001Sglebius# 29290001Sglebius# Except as contained in this notice, the name of the X Consortium shall not 30290001Sglebius# be used in advertising or otherwise to promote the sale, use or other deal- 31290001Sglebius# ings in this Software without prior written authorization from the X Consor- 32290001Sglebius# tium. 33290001Sglebius# 34290001Sglebius# 35290001Sglebius# FSF changes to this file are in the public domain. 36290001Sglebius# 37290001Sglebius# Calling this script install-sh is preferred over install.sh, to prevent 38290001Sglebius# `make' implicit rules from creating a file called install from it 39290001Sglebius# when there is no Makefile. 40290001Sglebius# 41290001Sglebius# This script is compatible with the BSD install script, but was written 42290001Sglebius# from scratch. 43290001Sglebius 44290001Sglebiusnl=' 45290001Sglebius' 46290001SglebiusIFS=" "" $nl" 47290001Sglebius 48290001Sglebius# set DOITPROG to echo to test this script 49290001Sglebius 50290001Sglebius# Don't use :- since 4.3BSD and earlier shells don't like it. 51290001Sglebiusdoit=${DOITPROG-} 52290001Sglebiusif test -z "$doit"; then 53290001Sglebius doit_exec=exec 54290001Sglebiuselse 55290001Sglebius doit_exec=$doit 56290001Sglebiusfi 57290001Sglebius 58290001Sglebius# Put in absolute file names if you don't have them in your path; 59290001Sglebius# or use environment vars. 60290001Sglebius 61290001Sglebiuschgrpprog=${CHGRPPROG-chgrp} 62290001Sglebiuschmodprog=${CHMODPROG-chmod} 63290001Sglebiuschownprog=${CHOWNPROG-chown} 64290001Sglebiuscmpprog=${CMPPROG-cmp} 65290001Sglebiuscpprog=${CPPROG-cp} 66290001Sglebiusmkdirprog=${MKDIRPROG-mkdir} 67290001Sglebiusmvprog=${MVPROG-mv} 68290001Sglebiusrmprog=${RMPROG-rm} 69290001Sglebiusstripprog=${STRIPPROG-strip} 70290001Sglebius 71290001Sglebiusposix_glob='?' 72290001Sglebiusinitialize_posix_glob=' 73290001Sglebius test "$posix_glob" != "?" || { 74290001Sglebius if (set -f) 2>/dev/null; then 75290001Sglebius posix_glob= 76290001Sglebius else 77290001Sglebius posix_glob=: 78290001Sglebius fi 79290001Sglebius } 80290001Sglebius' 81290001Sglebius 82290001Sglebiusposix_mkdir= 83290001Sglebius 84290001Sglebius# Desired mode of installed file. 85290001Sglebiusmode=0755 86290001Sglebius 87290001Sglebiuschgrpcmd= 88290001Sglebiuschmodcmd=$chmodprog 89290001Sglebiuschowncmd= 90290001Sglebiusmvcmd=$mvprog 91290001Sglebiusrmcmd="$rmprog -f" 92290001Sglebiusstripcmd= 93290001Sglebius 94290001Sglebiussrc= 95290001Sglebiusdst= 96290001Sglebiusdir_arg= 97290001Sglebiusdst_arg= 98290001Sglebius 99290001Sglebiuscopy_on_change=false 100290001Sglebiusno_target_directory= 101290001Sglebius 102290001Sglebiususage="\ 103290001SglebiusUsage: $0 [OPTION]... [-T] SRCFILE DSTFILE 104290001Sglebius or: $0 [OPTION]... SRCFILES... DIRECTORY 105290001Sglebius or: $0 [OPTION]... -t DIRECTORY SRCFILES... 106290001Sglebius or: $0 [OPTION]... -d DIRECTORIES... 107290001Sglebius 108290001SglebiusIn the 1st form, copy SRCFILE to DSTFILE. 109290001SglebiusIn the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 110290001SglebiusIn the 4th, create DIRECTORIES. 111290001Sglebius 112290001SglebiusOptions: 113290001Sglebius --help display this help and exit. 114290001Sglebius --version display version info and exit. 115290001Sglebius 116290001Sglebius -c (ignored) 117290001Sglebius -C install only if different (preserve the last data modification time) 118290001Sglebius -d create directories instead of installing files. 119290001Sglebius -g GROUP $chgrpprog installed files to GROUP. 120290001Sglebius -m MODE $chmodprog installed files to MODE. 121290001Sglebius -o USER $chownprog installed files to USER. 122290001Sglebius -s $stripprog installed files. 123290001Sglebius -t DIRECTORY install into DIRECTORY. 124290001Sglebius -T report an error if DSTFILE is a directory. 125290001Sglebius 126290001SglebiusEnvironment variables override the default commands: 127290001Sglebius CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 128290001Sglebius RMPROG STRIPPROG 129290001Sglebius" 130290001Sglebius 131290001Sglebiuswhile test $# -ne 0; do 132290001Sglebius case $1 in 133290001Sglebius -c) ;; 134290001Sglebius 135290001Sglebius -C) copy_on_change=true;; 136290001Sglebius 137290001Sglebius -d) dir_arg=true;; 138290001Sglebius 139290001Sglebius -g) chgrpcmd="$chgrpprog $2" 140290001Sglebius shift;; 141290001Sglebius 142290001Sglebius --help) echo "$usage"; exit $?;; 143290001Sglebius 144290001Sglebius -m) mode=$2 145290001Sglebius case $mode in 146290001Sglebius *' '* | *' '* | *' 147290001Sglebius'* | *'*'* | *'?'* | *'['*) 148290001Sglebius echo "$0: invalid mode: $mode" >&2 149290001Sglebius exit 1;; 150290001Sglebius esac 151290001Sglebius shift;; 152290001Sglebius 153290001Sglebius -o) chowncmd="$chownprog $2" 154290001Sglebius shift;; 155290001Sglebius 156290001Sglebius -s) stripcmd=$stripprog;; 157290001Sglebius 158290001Sglebius -t) dst_arg=$2 159290001Sglebius shift;; 160290001Sglebius 161290001Sglebius -T) no_target_directory=true;; 162290001Sglebius 163290001Sglebius --version) echo "$0 $scriptversion"; exit $?;; 164290001Sglebius 165290001Sglebius --) shift 166290001Sglebius break;; 167290001Sglebius 168290001Sglebius -*) echo "$0: invalid option: $1" >&2 169290001Sglebius exit 1;; 170290001Sglebius 171290001Sglebius *) break;; 172290001Sglebius esac 173290001Sglebius shift 174290001Sglebiusdone 175290001Sglebius 176290001Sglebiusif test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 177290001Sglebius # When -d is used, all remaining arguments are directories to create. 178290001Sglebius # When -t is used, the destination is already specified. 179290001Sglebius # Otherwise, the last argument is the destination. Remove it from $@. 180290001Sglebius for arg 181290001Sglebius do 182290001Sglebius if test -n "$dst_arg"; then 183290001Sglebius # $@ is not empty: it contains at least $arg. 184290001Sglebius set fnord "$@" "$dst_arg" 185290001Sglebius shift # fnord 186290001Sglebius fi 187290001Sglebius shift # arg 188290001Sglebius dst_arg=$arg 189290001Sglebius done 190290001Sglebiusfi 191290001Sglebius 192290001Sglebiusif test $# -eq 0; then 193290001Sglebius if test -z "$dir_arg"; then 194290001Sglebius echo "$0: no input file specified." >&2 195290001Sglebius exit 1 196290001Sglebius fi 197290001Sglebius # It's OK to call `install-sh -d' without argument. 198290001Sglebius # This can happen when creating conditional directories. 199290001Sglebius exit 0 200290001Sglebiusfi 201290001Sglebius 202290001Sglebiusif test -z "$dir_arg"; then 203290001Sglebius trap '(exit $?); exit' 1 2 13 15 204290001Sglebius 205290001Sglebius # Set umask so as not to create temps with too-generous modes. 206290001Sglebius # However, 'strip' requires both read and write access to temps. 207290001Sglebius case $mode in 208290001Sglebius # Optimize common cases. 209290001Sglebius *644) cp_umask=133;; 210290001Sglebius *755) cp_umask=22;; 211290001Sglebius 212290001Sglebius *[0-7]) 213290001Sglebius if test -z "$stripcmd"; then 214290001Sglebius u_plus_rw= 215290001Sglebius else 216290001Sglebius u_plus_rw='% 200' 217290001Sglebius fi 218290001Sglebius cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 219290001Sglebius *) 220290001Sglebius if test -z "$stripcmd"; then 221290001Sglebius u_plus_rw= 222290001Sglebius else 223290001Sglebius u_plus_rw=,u+rw 224290001Sglebius fi 225290001Sglebius cp_umask=$mode$u_plus_rw;; 226290001Sglebius esac 227290001Sglebiusfi 228290001Sglebius 229290001Sglebiusfor src 230290001Sglebiusdo 231290001Sglebius # Protect names starting with `-'. 232290001Sglebius case $src in 233290001Sglebius -*) src=./$src;; 234290001Sglebius esac 235290001Sglebius 236290001Sglebius if test -n "$dir_arg"; then 237290001Sglebius dst=$src 238290001Sglebius dstdir=$dst 239290001Sglebius test -d "$dstdir" 240290001Sglebius dstdir_status=$? 241290001Sglebius else 242290001Sglebius 243290001Sglebius # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 244290001Sglebius # might cause directories to be created, which would be especially bad 245290001Sglebius # if $src (and thus $dsttmp) contains '*'. 246290001Sglebius if test ! -f "$src" && test ! -d "$src"; then 247290001Sglebius echo "$0: $src does not exist." >&2 248290001Sglebius exit 1 249290001Sglebius fi 250290001Sglebius 251290001Sglebius if test -z "$dst_arg"; then 252290001Sglebius echo "$0: no destination specified." >&2 253290001Sglebius exit 1 254290001Sglebius fi 255290001Sglebius 256290001Sglebius dst=$dst_arg 257290001Sglebius # Protect names starting with `-'. 258290001Sglebius case $dst in 259290001Sglebius -*) dst=./$dst;; 260290001Sglebius esac 261290001Sglebius 262290001Sglebius # If destination is a directory, append the input filename; won't work 263290001Sglebius # if double slashes aren't ignored. 264290001Sglebius if test -d "$dst"; then 265290001Sglebius if test -n "$no_target_directory"; then 266290001Sglebius echo "$0: $dst_arg: Is a directory" >&2 267290001Sglebius exit 1 268290001Sglebius fi 269290001Sglebius dstdir=$dst 270290001Sglebius dst=$dstdir/`basename "$src"` 271290001Sglebius dstdir_status=0 272290001Sglebius else 273290001Sglebius # Prefer dirname, but fall back on a substitute if dirname fails. 274290001Sglebius dstdir=` 275290001Sglebius (dirname "$dst") 2>/dev/null || 276290001Sglebius expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 277290001Sglebius X"$dst" : 'X\(//\)[^/]' \| \ 278290001Sglebius X"$dst" : 'X\(//\)$' \| \ 279290001Sglebius X"$dst" : 'X\(/\)' \| . 2>/dev/null || 280290001Sglebius echo X"$dst" | 281290001Sglebius sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 282290001Sglebius s//\1/ 283290001Sglebius q 284290001Sglebius } 285290001Sglebius /^X\(\/\/\)[^/].*/{ 286290001Sglebius s//\1/ 287290001Sglebius q 288290001Sglebius } 289290001Sglebius /^X\(\/\/\)$/{ 290290001Sglebius s//\1/ 291290001Sglebius q 292290001Sglebius } 293290001Sglebius /^X\(\/\).*/{ 294290001Sglebius s//\1/ 295290001Sglebius q 296290001Sglebius } 297290001Sglebius s/.*/./; q' 298290001Sglebius ` 299290001Sglebius 300290001Sglebius test -d "$dstdir" 301290001Sglebius dstdir_status=$? 302290001Sglebius fi 303290001Sglebius fi 304290001Sglebius 305290001Sglebius obsolete_mkdir_used=false 306290001Sglebius 307290001Sglebius if test $dstdir_status != 0; then 308290001Sglebius case $posix_mkdir in 309290001Sglebius '') 310290001Sglebius # Create intermediate dirs using mode 755 as modified by the umask. 311290001Sglebius # This is like FreeBSD 'install' as of 1997-10-28. 312290001Sglebius umask=`umask` 313290001Sglebius case $stripcmd.$umask in 314290001Sglebius # Optimize common cases. 315290001Sglebius *[2367][2367]) mkdir_umask=$umask;; 316290001Sglebius .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 317290001Sglebius 318290001Sglebius *[0-7]) 319290001Sglebius mkdir_umask=`expr $umask + 22 \ 320290001Sglebius - $umask % 100 % 40 + $umask % 20 \ 321290001Sglebius - $umask % 10 % 4 + $umask % 2 322290001Sglebius `;; 323290001Sglebius *) mkdir_umask=$umask,go-w;; 324290001Sglebius esac 325290001Sglebius 326290001Sglebius # With -d, create the new directory with the user-specified mode. 327290001Sglebius # Otherwise, rely on $mkdir_umask. 328290001Sglebius if test -n "$dir_arg"; then 329290001Sglebius mkdir_mode=-m$mode 330290001Sglebius else 331290001Sglebius mkdir_mode= 332290001Sglebius fi 333290001Sglebius 334290001Sglebius posix_mkdir=false 335290001Sglebius case $umask in 336290001Sglebius *[123567][0-7][0-7]) 337290001Sglebius # POSIX mkdir -p sets u+wx bits regardless of umask, which 338290001Sglebius # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 339290001Sglebius ;; 340290001Sglebius *) 341290001Sglebius tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 342290001Sglebius trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 343290001Sglebius 344290001Sglebius if (umask $mkdir_umask && 345290001Sglebius exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 346290001Sglebius then 347290001Sglebius if test -z "$dir_arg" || { 348290001Sglebius # Check for POSIX incompatibilities with -m. 349290001Sglebius # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 350290001Sglebius # other-writeable bit of parent directory when it shouldn't. 351290001Sglebius # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 352290001Sglebius ls_ld_tmpdir=`ls -ld "$tmpdir"` 353290001Sglebius case $ls_ld_tmpdir in 354290001Sglebius d????-?r-*) different_mode=700;; 355290001Sglebius d????-?--*) different_mode=755;; 356290001Sglebius *) false;; 357290001Sglebius esac && 358290001Sglebius $mkdirprog -m$different_mode -p -- "$tmpdir" && { 359290001Sglebius ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 360290001Sglebius test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 361290001Sglebius } 362290001Sglebius } 363290001Sglebius then posix_mkdir=: 364290001Sglebius fi 365290001Sglebius rmdir "$tmpdir/d" "$tmpdir" 366290001Sglebius else 367290001Sglebius # Remove any dirs left behind by ancient mkdir implementations. 368290001Sglebius rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 369290001Sglebius fi 370290001Sglebius trap '' 0;; 371290001Sglebius esac;; 372290001Sglebius esac 373290001Sglebius 374290001Sglebius if 375290001Sglebius $posix_mkdir && ( 376290001Sglebius umask $mkdir_umask && 377290001Sglebius $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 378290001Sglebius ) 379290001Sglebius then : 380290001Sglebius else 381290001Sglebius 382290001Sglebius # The umask is ridiculous, or mkdir does not conform to POSIX, 383290001Sglebius # or it failed possibly due to a race condition. Create the 384290001Sglebius # directory the slow way, step by step, checking for races as we go. 385290001Sglebius 386290001Sglebius case $dstdir in 387290001Sglebius /*) prefix='/';; 388290001Sglebius -*) prefix='./';; 389290001Sglebius *) prefix='';; 390290001Sglebius esac 391290001Sglebius 392290001Sglebius eval "$initialize_posix_glob" 393290001Sglebius 394290001Sglebius oIFS=$IFS 395290001Sglebius IFS=/ 396290001Sglebius $posix_glob set -f 397290001Sglebius set fnord $dstdir 398290001Sglebius shift 399290001Sglebius $posix_glob set +f 400290001Sglebius IFS=$oIFS 401290001Sglebius 402290001Sglebius prefixes= 403290001Sglebius 404290001Sglebius for d 405290001Sglebius do 406290001Sglebius test -z "$d" && continue 407290001Sglebius 408290001Sglebius prefix=$prefix$d 409290001Sglebius if test -d "$prefix"; then 410290001Sglebius prefixes= 411290001Sglebius else 412290001Sglebius if $posix_mkdir; then 413290001Sglebius (umask=$mkdir_umask && 414290001Sglebius $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 415290001Sglebius # Don't fail if two instances are running concurrently. 416290001Sglebius test -d "$prefix" || exit 1 417290001Sglebius else 418290001Sglebius case $prefix in 419290001Sglebius *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 420290001Sglebius *) qprefix=$prefix;; 421290001Sglebius esac 422290001Sglebius prefixes="$prefixes '$qprefix'" 423290001Sglebius fi 424290001Sglebius fi 425290001Sglebius prefix=$prefix/ 426290001Sglebius done 427290001Sglebius 428290001Sglebius if test -n "$prefixes"; then 429290001Sglebius # Don't fail if two instances are running concurrently. 430290001Sglebius (umask $mkdir_umask && 431290001Sglebius eval "\$doit_exec \$mkdirprog $prefixes") || 432290001Sglebius test -d "$dstdir" || exit 1 433290001Sglebius obsolete_mkdir_used=true 434290001Sglebius fi 435290001Sglebius fi 436290001Sglebius fi 437290001Sglebius 438290001Sglebius if test -n "$dir_arg"; then 439290001Sglebius { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 440290001Sglebius { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 441290001Sglebius { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 442290001Sglebius test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 443290001Sglebius else 444290001Sglebius 445290001Sglebius # Make a couple of temp file names in the proper directory. 446290001Sglebius dsttmp=$dstdir/_inst.$$_ 447290001Sglebius rmtmp=$dstdir/_rm.$$_ 448290001Sglebius 449290001Sglebius # Trap to clean up those temp files at exit. 450290001Sglebius trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 451290001Sglebius 452290001Sglebius # Copy the file name to the temp name. 453290001Sglebius (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 454290001Sglebius 455290001Sglebius # and set any options; do chmod last to preserve setuid bits. 456290001Sglebius # 457290001Sglebius # If any of these fail, we abort the whole thing. If we want to 458290001Sglebius # ignore errors from any of these, just make sure not to ignore 459290001Sglebius # errors from the above "$doit $cpprog $src $dsttmp" command. 460290001Sglebius # 461290001Sglebius { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 462290001Sglebius { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 463290001Sglebius { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 464290001Sglebius { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 465290001Sglebius 466290001Sglebius # If -C, don't bother to copy if it wouldn't change the file. 467290001Sglebius if $copy_on_change && 468290001Sglebius old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 469290001Sglebius new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 470290001Sglebius 471290001Sglebius eval "$initialize_posix_glob" && 472290001Sglebius $posix_glob set -f && 473290001Sglebius set X $old && old=:$2:$4:$5:$6 && 474290001Sglebius set X $new && new=:$2:$4:$5:$6 && 475290001Sglebius $posix_glob set +f && 476290001Sglebius 477290001Sglebius test "$old" = "$new" && 478290001Sglebius $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 479290001Sglebius then 480290001Sglebius rm -f "$dsttmp" 481290001Sglebius else 482290001Sglebius # Rename the file to the real destination. 483290001Sglebius $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 484290001Sglebius 485290001Sglebius # The rename failed, perhaps because mv can't rename something else 486290001Sglebius # to itself, or perhaps because mv is so ancient that it does not 487290001Sglebius # support -f. 488290001Sglebius { 489290001Sglebius # Now remove or move aside any old file at destination location. 490290001Sglebius # We try this two ways since rm can't unlink itself on some 491290001Sglebius # systems and the destination file might be busy for other 492290001Sglebius # reasons. In this case, the final cleanup might fail but the new 493290001Sglebius # file should still install successfully. 494290001Sglebius { 495290001Sglebius test ! -f "$dst" || 496290001Sglebius $doit $rmcmd -f "$dst" 2>/dev/null || 497290001Sglebius { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 498290001Sglebius { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 499290001Sglebius } || 500290001Sglebius { echo "$0: cannot unlink or rename $dst" >&2 501290001Sglebius (exit 1); exit 1 502290001Sglebius } 503290001Sglebius } && 504290001Sglebius 505290001Sglebius # Now rename the file to the real destination. 506290001Sglebius $doit $mvcmd "$dsttmp" "$dst" 507290001Sglebius } 508290001Sglebius fi || exit 1 509290001Sglebius 510290001Sglebius trap '' 0 511290001Sglebius fi 512290001Sglebiusdone 513290001Sglebius 514290001Sglebius# Local variables: 515290001Sglebius# eval: (add-hook 'write-file-hooks 'time-stamp) 516290001Sglebius# time-stamp-start: "scriptversion=" 517290001Sglebius# time-stamp-format: "%:y-%02m-%02d.%02H" 518290001Sglebius# time-stamp-time-zone: "UTC" 519290001Sglebius# time-stamp-end: "; # UTC" 520290001Sglebius# End: 521