ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/lsys/install-sh
(Generate patch)

Comparing lsys/install-sh (file contents):
Revision 1.2 by root, Thu Apr 29 12:42:14 2010 UTC vs.
Revision 1.3 by root, Wed Nov 7 12:50:17 2018 UTC

1#!/bin/sh 1#!/bin/sh
2# install - install a program, script, or datafile 2# install - install a program, script, or datafile
3 3
4scriptversion=2006-12-25.00 4scriptversion=2014-09-12.12; # UTC
5 5
6# This originates from X11R5 (mit/util/scripts/install.sh), which was 6# This originates from X11R5 (mit/util/scripts/install.sh), which was
7# later released in X11R6 (xc/config/util/install.sh) with the 7# later released in X11R6 (xc/config/util/install.sh) with the
8# following copyright and license. 8# following copyright and license.
9# 9#
33# 33#
34# 34#
35# FSF changes to this file are in the public domain. 35# FSF changes to this file are in the public domain.
36# 36#
37# Calling this script install-sh is preferred over install.sh, to prevent 37# Calling this script install-sh is preferred over install.sh, to prevent
38# `make' implicit rules from creating a file called install from it 38# 'make' implicit rules from creating a file called install from it
39# when there is no Makefile. 39# when there is no Makefile.
40# 40#
41# This script is compatible with the BSD install script, but was written 41# This script is compatible with the BSD install script, but was written
42# from scratch. 42# from scratch.
43 43
44tab=' '
44nl=' 45nl='
45' 46'
46IFS=" "" $nl" 47IFS=" $tab$nl"
47 48
48# set DOITPROG to echo to test this script 49# Set DOITPROG to "echo" to test this script.
49 50
50# Don't use :- since 4.3BSD and earlier shells don't like it.
51doit=${DOITPROG-} 51doit=${DOITPROG-}
52if test -z "$doit"; then
53 doit_exec=exec
54else
55 doit_exec=$doit 52doit_exec=${doit:-exec}
56fi
57 53
58# Put in absolute file names if you don't have them in your path; 54# Put in absolute file names if you don't have them in your path;
59# or use environment vars. 55# or use environment vars.
60 56
61chgrpprog=${CHGRPPROG-chgrp} 57chgrpprog=${CHGRPPROG-chgrp}
66mkdirprog=${MKDIRPROG-mkdir} 62mkdirprog=${MKDIRPROG-mkdir}
67mvprog=${MVPROG-mv} 63mvprog=${MVPROG-mv}
68rmprog=${RMPROG-rm} 64rmprog=${RMPROG-rm}
69stripprog=${STRIPPROG-strip} 65stripprog=${STRIPPROG-strip}
70 66
71posix_glob='?'
72initialize_posix_glob='
73 test "$posix_glob" != "?" || {
74 if (set -f) 2>/dev/null; then
75 posix_glob=
76 else
77 posix_glob=:
78 fi
79 }
80'
81
82posix_mkdir= 67posix_mkdir=
83 68
84# Desired mode of installed file. 69# Desired mode of installed file.
85mode=0755 70mode=0755
86 71
95dst= 80dst=
96dir_arg= 81dir_arg=
97dst_arg= 82dst_arg=
98 83
99copy_on_change=false 84copy_on_change=false
100no_target_directory= 85is_target_a_directory=possibly
101 86
102usage="\ 87usage="\
103Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 88Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
104 or: $0 [OPTION]... SRCFILES... DIRECTORY 89 or: $0 [OPTION]... SRCFILES... DIRECTORY
105 or: $0 [OPTION]... -t DIRECTORY SRCFILES... 90 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
135 -C) copy_on_change=true;; 120 -C) copy_on_change=true;;
136 121
137 -d) dir_arg=true;; 122 -d) dir_arg=true;;
138 123
139 -g) chgrpcmd="$chgrpprog $2" 124 -g) chgrpcmd="$chgrpprog $2"
140 shift;; 125 shift;;
141 126
142 --help) echo "$usage"; exit $?;; 127 --help) echo "$usage"; exit $?;;
143 128
144 -m) mode=$2 129 -m) mode=$2
145 case $mode in 130 case $mode in
146 *' '* | *' '* | *' 131 *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
147'* | *'*'* | *'?'* | *'['*)
148 echo "$0: invalid mode: $mode" >&2 132 echo "$0: invalid mode: $mode" >&2
149 exit 1;; 133 exit 1;;
150 esac 134 esac
151 shift;; 135 shift;;
152 136
153 -o) chowncmd="$chownprog $2" 137 -o) chowncmd="$chownprog $2"
154 shift;; 138 shift;;
155 139
156 -s) stripcmd=$stripprog;; 140 -s) stripcmd=$stripprog;;
157 141
142 -t)
143 is_target_a_directory=always
158 -t) dst_arg=$2 144 dst_arg=$2
159 shift;; 145 # Protect names problematic for 'test' and other utilities.
146 case $dst_arg in
147 -* | [=\(\)!]) dst_arg=./$dst_arg;;
148 esac
149 shift;;
160 150
161 -T) no_target_directory=true;; 151 -T) is_target_a_directory=never;;
162 152
163 --version) echo "$0 $scriptversion"; exit $?;; 153 --version) echo "$0 $scriptversion"; exit $?;;
164 154
165 --) shift 155 --) shift
166 break;; 156 break;;
167 157
168 -*) echo "$0: invalid option: $1" >&2 158 -*) echo "$0: invalid option: $1" >&2
169 exit 1;; 159 exit 1;;
170 160
171 *) break;; 161 *) break;;
172 esac 162 esac
173 shift 163 shift
174done 164done
165
166# We allow the use of options -d and -T together, by making -d
167# take the precedence; this is for compatibility with GNU install.
168
169if test -n "$dir_arg"; then
170 if test -n "$dst_arg"; then
171 echo "$0: target directory not allowed when installing a directory." >&2
172 exit 1
173 fi
174fi
175 175
176if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 176if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
177 # When -d is used, all remaining arguments are directories to create. 177 # When -d is used, all remaining arguments are directories to create.
178 # When -t is used, the destination is already specified. 178 # When -t is used, the destination is already specified.
179 # Otherwise, the last argument is the destination. Remove it from $@. 179 # Otherwise, the last argument is the destination. Remove it from $@.
184 set fnord "$@" "$dst_arg" 184 set fnord "$@" "$dst_arg"
185 shift # fnord 185 shift # fnord
186 fi 186 fi
187 shift # arg 187 shift # arg
188 dst_arg=$arg 188 dst_arg=$arg
189 # Protect names problematic for 'test' and other utilities.
190 case $dst_arg in
191 -* | [=\(\)!]) dst_arg=./$dst_arg;;
192 esac
189 done 193 done
190fi 194fi
191 195
192if test $# -eq 0; then 196if test $# -eq 0; then
193 if test -z "$dir_arg"; then 197 if test -z "$dir_arg"; then
194 echo "$0: no input file specified." >&2 198 echo "$0: no input file specified." >&2
195 exit 1 199 exit 1
196 fi 200 fi
197 # It's OK to call `install-sh -d' without argument. 201 # It's OK to call 'install-sh -d' without argument.
198 # This can happen when creating conditional directories. 202 # This can happen when creating conditional directories.
199 exit 0 203 exit 0
200fi 204fi
201 205
202if test -z "$dir_arg"; then 206if test -z "$dir_arg"; then
203 trap '(exit $?); exit' 1 2 13 15 207 if test $# -gt 1 || test "$is_target_a_directory" = always; then
208 if test ! -d "$dst_arg"; then
209 echo "$0: $dst_arg: Is not a directory." >&2
210 exit 1
211 fi
212 fi
213fi
214
215if test -z "$dir_arg"; then
216 do_exit='(exit $ret); exit $ret'
217 trap "ret=129; $do_exit" 1
218 trap "ret=130; $do_exit" 2
219 trap "ret=141; $do_exit" 13
220 trap "ret=143; $do_exit" 15
204 221
205 # Set umask so as not to create temps with too-generous modes. 222 # Set umask so as not to create temps with too-generous modes.
206 # However, 'strip' requires both read and write access to temps. 223 # However, 'strip' requires both read and write access to temps.
207 case $mode in 224 case $mode in
208 # Optimize common cases. 225 # Optimize common cases.
209 *644) cp_umask=133;; 226 *644) cp_umask=133;;
210 *755) cp_umask=22;; 227 *755) cp_umask=22;;
211 228
212 *[0-7]) 229 *[0-7])
213 if test -z "$stripcmd"; then 230 if test -z "$stripcmd"; then
214 u_plus_rw= 231 u_plus_rw=
215 else 232 else
216 u_plus_rw='% 200' 233 u_plus_rw='% 200'
217 fi 234 fi
218 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 235 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
219 *) 236 *)
220 if test -z "$stripcmd"; then 237 if test -z "$stripcmd"; then
221 u_plus_rw= 238 u_plus_rw=
222 else 239 else
223 u_plus_rw=,u+rw 240 u_plus_rw=,u+rw
224 fi 241 fi
225 cp_umask=$mode$u_plus_rw;; 242 cp_umask=$mode$u_plus_rw;;
226 esac 243 esac
227fi 244fi
228 245
229for src 246for src
230do 247do
231 # Protect names starting with `-'. 248 # Protect names problematic for 'test' and other utilities.
232 case $src in 249 case $src in
233 -*) src=./$src;; 250 -* | [=\(\)!]) src=./$src;;
234 esac 251 esac
235 252
236 if test -n "$dir_arg"; then 253 if test -n "$dir_arg"; then
237 dst=$src 254 dst=$src
238 dstdir=$dst 255 dstdir=$dst
250 267
251 if test -z "$dst_arg"; then 268 if test -z "$dst_arg"; then
252 echo "$0: no destination specified." >&2 269 echo "$0: no destination specified." >&2
253 exit 1 270 exit 1
254 fi 271 fi
255
256 dst=$dst_arg 272 dst=$dst_arg
257 # Protect names starting with `-'.
258 case $dst in
259 -*) dst=./$dst;;
260 esac
261 273
262 # If destination is a directory, append the input filename; won't work 274 # If destination is a directory, append the input filename; won't work
263 # if double slashes aren't ignored. 275 # if double slashes aren't ignored.
264 if test -d "$dst"; then 276 if test -d "$dst"; then
265 if test -n "$no_target_directory"; then 277 if test "$is_target_a_directory" = never; then
266 echo "$0: $dst_arg: Is a directory" >&2 278 echo "$0: $dst_arg: Is a directory" >&2
267 exit 1 279 exit 1
268 fi 280 fi
269 dstdir=$dst 281 dstdir=$dst
270 dst=$dstdir/`basename "$src"` 282 dst=$dstdir/`basename "$src"`
271 dstdir_status=0 283 dstdir_status=0
272 else 284 else
273 # Prefer dirname, but fall back on a substitute if dirname fails. 285 dstdir=`dirname "$dst"`
274 dstdir=`
275 (dirname "$dst") 2>/dev/null ||
276 expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
277 X"$dst" : 'X\(//\)[^/]' \| \
278 X"$dst" : 'X\(//\)$' \| \
279 X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
280 echo X"$dst" |
281 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
282 s//\1/
283 q
284 }
285 /^X\(\/\/\)[^/].*/{
286 s//\1/
287 q
288 }
289 /^X\(\/\/\)$/{
290 s//\1/
291 q
292 }
293 /^X\(\/\).*/{
294 s//\1/
295 q
296 }
297 s/.*/./; q'
298 `
299
300 test -d "$dstdir" 286 test -d "$dstdir"
301 dstdir_status=$? 287 dstdir_status=$?
302 fi 288 fi
303 fi 289 fi
304 290
305 obsolete_mkdir_used=false 291 obsolete_mkdir_used=false
306 292
307 if test $dstdir_status != 0; then 293 if test $dstdir_status != 0; then
308 case $posix_mkdir in 294 case $posix_mkdir in
309 '') 295 '')
310 # Create intermediate dirs using mode 755 as modified by the umask. 296 # Create intermediate dirs using mode 755 as modified by the umask.
311 # This is like FreeBSD 'install' as of 1997-10-28. 297 # This is like FreeBSD 'install' as of 1997-10-28.
312 umask=`umask` 298 umask=`umask`
313 case $stripcmd.$umask in 299 case $stripcmd.$umask in
314 # Optimize common cases. 300 # Optimize common cases.
315 *[2367][2367]) mkdir_umask=$umask;; 301 *[2367][2367]) mkdir_umask=$umask;;
316 .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 302 .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
317 303
318 *[0-7]) 304 *[0-7])
319 mkdir_umask=`expr $umask + 22 \ 305 mkdir_umask=`expr $umask + 22 \
320 - $umask % 100 % 40 + $umask % 20 \ 306 - $umask % 100 % 40 + $umask % 20 \
321 - $umask % 10 % 4 + $umask % 2 307 - $umask % 10 % 4 + $umask % 2
322 `;; 308 `;;
323 *) mkdir_umask=$umask,go-w;; 309 *) mkdir_umask=$umask,go-w;;
324 esac 310 esac
325 311
326 # With -d, create the new directory with the user-specified mode. 312 # With -d, create the new directory with the user-specified mode.
327 # Otherwise, rely on $mkdir_umask. 313 # Otherwise, rely on $mkdir_umask.
328 if test -n "$dir_arg"; then 314 if test -n "$dir_arg"; then
329 mkdir_mode=-m$mode 315 mkdir_mode=-m$mode
330 else 316 else
331 mkdir_mode= 317 mkdir_mode=
332 fi 318 fi
333 319
334 posix_mkdir=false 320 posix_mkdir=false
335 case $umask in 321 case $umask in
336 *[123567][0-7][0-7]) 322 *[123567][0-7][0-7])
337 # POSIX mkdir -p sets u+wx bits regardless of umask, which 323 # POSIX mkdir -p sets u+wx bits regardless of umask, which
338 # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 324 # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
339 ;; 325 ;;
340 *) 326 *)
327 # $RANDOM is not portable (e.g. dash); use it when possible to
328 # lower collision chance
341 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 329 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
342 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 330 trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
343 331
332 # As "mkdir -p" follows symlinks and we work in /tmp possibly; so
333 # create the $tmpdir first (and fail if unsuccessful) to make sure
334 # that nobody tries to guess the $tmpdir name.
344 if (umask $mkdir_umask && 335 if (umask $mkdir_umask &&
336 $mkdirprog $mkdir_mode "$tmpdir" &&
345 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 337 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
346 then 338 then
347 if test -z "$dir_arg" || { 339 if test -z "$dir_arg" || {
348 # Check for POSIX incompatibilities with -m. 340 # Check for POSIX incompatibilities with -m.
349 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 341 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
350 # other-writeable bit of parent directory when it shouldn't. 342 # other-writable bit of parent directory when it shouldn't.
351 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 343 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
352 ls_ld_tmpdir=`ls -ld "$tmpdir"` 344 test_tmpdir="$tmpdir/a"
353 case $ls_ld_tmpdir in 345 ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
346 case $ls_ld_tmpdir in
354 d????-?r-*) different_mode=700;; 347 d????-?r-*) different_mode=700;;
355 d????-?--*) different_mode=755;; 348 d????-?--*) different_mode=755;;
356 *) false;; 349 *) false;;
357 esac && 350 esac &&
358 $mkdirprog -m$different_mode -p -- "$tmpdir" && { 351 $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
359 ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 352 ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
360 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 353 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
361 } 354 }
362 } 355 }
363 then posix_mkdir=: 356 then posix_mkdir=:
364 fi 357 fi
365 rmdir "$tmpdir/d" "$tmpdir" 358 rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
366 else 359 else
367 # Remove any dirs left behind by ancient mkdir implementations. 360 # Remove any dirs left behind by ancient mkdir implementations.
368 rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 361 rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
369 fi 362 fi
370 trap '' 0;; 363 trap '' 0;;
371 esac;; 364 esac;;
372 esac 365 esac
373 366
374 if 367 if
375 $posix_mkdir && ( 368 $posix_mkdir && (
376 umask $mkdir_umask && 369 umask $mkdir_umask &&
377 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 370 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
378 ) 371 )
379 then : 372 then :
380 else 373 else
381 374
382 # The umask is ridiculous, or mkdir does not conform to POSIX, 375 # The umask is ridiculous, or mkdir does not conform to POSIX,
383 # or it failed possibly due to a race condition. Create the 376 # or it failed possibly due to a race condition. Create the
384 # directory the slow way, step by step, checking for races as we go. 377 # directory the slow way, step by step, checking for races as we go.
385 378
386 case $dstdir in 379 case $dstdir in
387 /*) prefix='/';; 380 /*) prefix='/';;
388 -*) prefix='./';; 381 [-=\(\)!]*) prefix='./';;
389 *) prefix='';; 382 *) prefix='';;
390 esac 383 esac
391
392 eval "$initialize_posix_glob"
393 384
394 oIFS=$IFS 385 oIFS=$IFS
395 IFS=/ 386 IFS=/
396 $posix_glob set -f 387 set -f
397 set fnord $dstdir 388 set fnord $dstdir
398 shift 389 shift
399 $posix_glob set +f 390 set +f
400 IFS=$oIFS 391 IFS=$oIFS
401 392
402 prefixes= 393 prefixes=
403 394
404 for d 395 for d
405 do 396 do
406 test -z "$d" && continue 397 test X"$d" = X && continue
407 398
408 prefix=$prefix$d 399 prefix=$prefix$d
409 if test -d "$prefix"; then 400 if test -d "$prefix"; then
410 prefixes= 401 prefixes=
411 else 402 else
412 if $posix_mkdir; then 403 if $posix_mkdir; then
413 (umask=$mkdir_umask && 404 (umask=$mkdir_umask &&
414 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 405 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
415 # Don't fail if two instances are running concurrently. 406 # Don't fail if two instances are running concurrently.
416 test -d "$prefix" || exit 1 407 test -d "$prefix" || exit 1
417 else 408 else
418 case $prefix in 409 case $prefix in
419 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 410 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
420 *) qprefix=$prefix;; 411 *) qprefix=$prefix;;
421 esac 412 esac
422 prefixes="$prefixes '$qprefix'" 413 prefixes="$prefixes '$qprefix'"
423 fi 414 fi
424 fi 415 fi
425 prefix=$prefix/ 416 prefix=$prefix/
426 done 417 done
427 418
428 if test -n "$prefixes"; then 419 if test -n "$prefixes"; then
429 # Don't fail if two instances are running concurrently. 420 # Don't fail if two instances are running concurrently.
430 (umask $mkdir_umask && 421 (umask $mkdir_umask &&
431 eval "\$doit_exec \$mkdirprog $prefixes") || 422 eval "\$doit_exec \$mkdirprog $prefixes") ||
432 test -d "$dstdir" || exit 1 423 test -d "$dstdir" || exit 1
433 obsolete_mkdir_used=true 424 obsolete_mkdir_used=true
434 fi 425 fi
435 fi 426 fi
436 fi 427 fi
437 428
438 if test -n "$dir_arg"; then 429 if test -n "$dir_arg"; then
463 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 454 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
464 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 455 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
465 456
466 # If -C, don't bother to copy if it wouldn't change the file. 457 # If -C, don't bother to copy if it wouldn't change the file.
467 if $copy_on_change && 458 if $copy_on_change &&
468 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 459 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
469 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 460 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
470 461 set -f &&
471 eval "$initialize_posix_glob" &&
472 $posix_glob set -f &&
473 set X $old && old=:$2:$4:$5:$6 && 462 set X $old && old=:$2:$4:$5:$6 &&
474 set X $new && new=:$2:$4:$5:$6 && 463 set X $new && new=:$2:$4:$5:$6 &&
475 $posix_glob set +f && 464 set +f &&
476
477 test "$old" = "$new" && 465 test "$old" = "$new" &&
478 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 466 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
479 then 467 then
480 rm -f "$dsttmp" 468 rm -f "$dsttmp"
481 else 469 else
484 472
485 # The rename failed, perhaps because mv can't rename something else 473 # The rename failed, perhaps because mv can't rename something else
486 # to itself, or perhaps because mv is so ancient that it does not 474 # to itself, or perhaps because mv is so ancient that it does not
487 # support -f. 475 # support -f.
488 { 476 {
489 # Now remove or move aside any old file at destination location. 477 # Now remove or move aside any old file at destination location.
490 # We try this two ways since rm can't unlink itself on some 478 # We try this two ways since rm can't unlink itself on some
491 # systems and the destination file might be busy for other 479 # systems and the destination file might be busy for other
492 # reasons. In this case, the final cleanup might fail but the new 480 # reasons. In this case, the final cleanup might fail but the new
493 # file should still install successfully. 481 # file should still install successfully.
494 { 482 {
495 test ! -f "$dst" || 483 test ! -f "$dst" ||
496 $doit $rmcmd -f "$dst" 2>/dev/null || 484 $doit $rmcmd -f "$dst" 2>/dev/null ||
497 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 485 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
498 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 486 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
499 } || 487 } ||
500 { echo "$0: cannot unlink or rename $dst" >&2 488 { echo "$0: cannot unlink or rename $dst" >&2
501 (exit 1); exit 1 489 (exit 1); exit 1
502 } 490 }
503 } && 491 } &&
504 492
505 # Now rename the file to the real destination. 493 # Now rename the file to the real destination.
506 $doit $mvcmd "$dsttmp" "$dst" 494 $doit $mvcmd "$dsttmp" "$dst"
507 } 495 }
508 fi || exit 1 496 fi || exit 1
509 497
510 trap '' 0 498 trap '' 0
511 fi 499 fi
513 501
514# Local variables: 502# Local variables:
515# eval: (add-hook 'write-file-hooks 'time-stamp) 503# eval: (add-hook 'write-file-hooks 'time-stamp)
516# time-stamp-start: "scriptversion=" 504# time-stamp-start: "scriptversion="
517# time-stamp-format: "%:y-%02m-%02d.%02H" 505# time-stamp-format: "%:y-%02m-%02d.%02H"
506# time-stamp-time-zone: "UTC"
518# time-stamp-end: "$" 507# time-stamp-end: "; # UTC"
519# End: 508# End:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines