comparison install-sh @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 77e2b8dfacca
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 #!/bin/sh 1 #!/bin/sh
2 # install - install a program, script, or datafile 2 # install - install a program, script, or datafile
3 3
4 scriptversion=2009-04-28.21; # UTC 4 scriptversion=2013-12-25.23; # 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
44 tab=' '
44 nl=' 45 nl='
45 ' 46 '
46 IFS=" "" $nl" 47 IFS=" $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.
51 doit=${DOITPROG-} 51 doit=${DOITPROG-}
52 if test -z "$doit"; then 52 doit_exec=${doit:-exec}
53 doit_exec=exec
54 else
55 doit_exec=$doit
56 fi
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
61 chgrpprog=${CHGRPPROG-chgrp} 57 chgrpprog=${CHGRPPROG-chgrp}
66 mkdirprog=${MKDIRPROG-mkdir} 62 mkdirprog=${MKDIRPROG-mkdir}
67 mvprog=${MVPROG-mv} 63 mvprog=${MVPROG-mv}
68 rmprog=${RMPROG-rm} 64 rmprog=${RMPROG-rm}
69 stripprog=${STRIPPROG-strip} 65 stripprog=${STRIPPROG-strip}
70 66
71 posix_glob='?'
72 initialize_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
82 posix_mkdir= 67 posix_mkdir=
83 68
84 # Desired mode of installed file. 69 # Desired mode of installed file.
85 mode=0755 70 mode=0755
86 71
95 dst= 80 dst=
96 dir_arg= 81 dir_arg=
97 dst_arg= 82 dst_arg=
98 83
99 copy_on_change=false 84 copy_on_change=false
100 no_target_directory= 85 is_target_a_directory=possibly
101 86
102 usage="\ 87 usage="\
103 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 88 Usage: $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 '* | *'*'* | *'?'* | *'['*) 132 echo "$0: invalid mode: $mode" >&2
148 echo "$0: invalid mode: $mode" >&2 133 exit 1;;
149 exit 1;; 134 esac
150 esac 135 shift;;
151 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
158 -t) dst_arg=$2 142 -t)
159 shift;; 143 is_target_a_directory=always
160 144 dst_arg=$2
161 -T) no_target_directory=true;; 145 # Protect names problematic for 'test' and other utilities.
146 case $dst_arg in
147 -* | [=\(\)!]) dst_arg=./$dst_arg;;
148 esac
149 shift;;
150
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
174 done 164 done
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
169 if 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
174 fi
175 175
176 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 176 if 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
190 fi 194 fi
191 195
192 if test $# -eq 0; then 196 if 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
200 fi 204 fi
201 205
202 if test -z "$dir_arg"; then 206 if 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
213 fi
214
215 if 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
227 fi 244 fi
228 245
229 for src 246 for src
230 do 247 do
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 *)
341 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 327 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
342 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 328 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
343 329
344 if (umask $mkdir_umask && 330 if (umask $mkdir_umask &&
345 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 331 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
346 then 332 then
347 if test -z "$dir_arg" || { 333 if test -z "$dir_arg" || {
348 # Check for POSIX incompatibilities with -m. 334 # Check for POSIX incompatibilities with -m.
349 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 335 # 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. 336 # other-writable bit of parent directory when it shouldn't.
351 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 337 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
352 ls_ld_tmpdir=`ls -ld "$tmpdir"` 338 ls_ld_tmpdir=`ls -ld "$tmpdir"`
353 case $ls_ld_tmpdir in 339 case $ls_ld_tmpdir in
354 d????-?r-*) different_mode=700;; 340 d????-?r-*) different_mode=700;;
355 d????-?--*) different_mode=755;; 341 d????-?--*) different_mode=755;;
356 *) false;; 342 *) false;;
357 esac && 343 esac &&
358 $mkdirprog -m$different_mode -p -- "$tmpdir" && { 344 $mkdirprog -m$different_mode -p -- "$tmpdir" && {
359 ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 345 ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
360 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 346 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
361 } 347 }
362 } 348 }
363 then posix_mkdir=: 349 then posix_mkdir=:
364 fi 350 fi
365 rmdir "$tmpdir/d" "$tmpdir" 351 rmdir "$tmpdir/d" "$tmpdir"
366 else 352 else
367 # Remove any dirs left behind by ancient mkdir implementations. 353 # Remove any dirs left behind by ancient mkdir implementations.
368 rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 354 rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
369 fi 355 fi
370 trap '' 0;; 356 trap '' 0;;
371 esac;; 357 esac;;
372 esac 358 esac
373 359
374 if 360 if
375 $posix_mkdir && ( 361 $posix_mkdir && (
376 umask $mkdir_umask && 362 umask $mkdir_umask &&
377 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 363 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
378 ) 364 )
379 then : 365 then :
380 else 366 else
381 367
382 # The umask is ridiculous, or mkdir does not conform to POSIX, 368 # The umask is ridiculous, or mkdir does not conform to POSIX,
383 # or it failed possibly due to a race condition. Create the 369 # 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. 370 # directory the slow way, step by step, checking for races as we go.
385 371
386 case $dstdir in 372 case $dstdir in
387 /*) prefix='/';; 373 /*) prefix='/';;
388 -*) prefix='./';; 374 [-=\(\)!]*) prefix='./';;
389 *) prefix='';; 375 *) prefix='';;
390 esac 376 esac
391
392 eval "$initialize_posix_glob"
393 377
394 oIFS=$IFS 378 oIFS=$IFS
395 IFS=/ 379 IFS=/
396 $posix_glob set -f 380 set -f
397 set fnord $dstdir 381 set fnord $dstdir
398 shift 382 shift
399 $posix_glob set +f 383 set +f
400 IFS=$oIFS 384 IFS=$oIFS
401 385
402 prefixes= 386 prefixes=
403 387
404 for d 388 for d
405 do 389 do
406 test -z "$d" && continue 390 test X"$d" = X && continue
407 391
408 prefix=$prefix$d 392 prefix=$prefix$d
409 if test -d "$prefix"; then 393 if test -d "$prefix"; then
410 prefixes= 394 prefixes=
411 else 395 else
412 if $posix_mkdir; then 396 if $posix_mkdir; then
413 (umask=$mkdir_umask && 397 (umask=$mkdir_umask &&
414 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 398 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
415 # Don't fail if two instances are running concurrently. 399 # Don't fail if two instances are running concurrently.
416 test -d "$prefix" || exit 1 400 test -d "$prefix" || exit 1
417 else 401 else
418 case $prefix in 402 case $prefix in
419 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 403 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
420 *) qprefix=$prefix;; 404 *) qprefix=$prefix;;
421 esac 405 esac
422 prefixes="$prefixes '$qprefix'" 406 prefixes="$prefixes '$qprefix'"
423 fi 407 fi
424 fi 408 fi
425 prefix=$prefix/ 409 prefix=$prefix/
426 done 410 done
427 411
428 if test -n "$prefixes"; then 412 if test -n "$prefixes"; then
429 # Don't fail if two instances are running concurrently. 413 # Don't fail if two instances are running concurrently.
430 (umask $mkdir_umask && 414 (umask $mkdir_umask &&
431 eval "\$doit_exec \$mkdirprog $prefixes") || 415 eval "\$doit_exec \$mkdirprog $prefixes") ||
432 test -d "$dstdir" || exit 1 416 test -d "$dstdir" || exit 1
433 obsolete_mkdir_used=true 417 obsolete_mkdir_used=true
434 fi 418 fi
435 fi 419 fi
436 fi 420 fi
437 421
438 if test -n "$dir_arg"; then 422 if test -n "$dir_arg"; then
463 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 447 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
464 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 448 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
465 449
466 # If -C, don't bother to copy if it wouldn't change the file. 450 # If -C, don't bother to copy if it wouldn't change the file.
467 if $copy_on_change && 451 if $copy_on_change &&
468 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 452 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
469 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 453 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
470 454 set -f &&
471 eval "$initialize_posix_glob" &&
472 $posix_glob set -f &&
473 set X $old && old=:$2:$4:$5:$6 && 455 set X $old && old=:$2:$4:$5:$6 &&
474 set X $new && new=:$2:$4:$5:$6 && 456 set X $new && new=:$2:$4:$5:$6 &&
475 $posix_glob set +f && 457 set +f &&
476
477 test "$old" = "$new" && 458 test "$old" = "$new" &&
478 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 459 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
479 then 460 then
480 rm -f "$dsttmp" 461 rm -f "$dsttmp"
481 else 462 else
484 465
485 # The rename failed, perhaps because mv can't rename something else 466 # 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 467 # to itself, or perhaps because mv is so ancient that it does not
487 # support -f. 468 # support -f.
488 { 469 {
489 # Now remove or move aside any old file at destination location. 470 # 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 471 # We try this two ways since rm can't unlink itself on some
491 # systems and the destination file might be busy for other 472 # systems and the destination file might be busy for other
492 # reasons. In this case, the final cleanup might fail but the new 473 # reasons. In this case, the final cleanup might fail but the new
493 # file should still install successfully. 474 # file should still install successfully.
494 { 475 {
495 test ! -f "$dst" || 476 test ! -f "$dst" ||
496 $doit $rmcmd -f "$dst" 2>/dev/null || 477 $doit $rmcmd -f "$dst" 2>/dev/null ||
497 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 478 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
498 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 479 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
499 } || 480 } ||
500 { echo "$0: cannot unlink or rename $dst" >&2 481 { echo "$0: cannot unlink or rename $dst" >&2
501 (exit 1); exit 1 482 (exit 1); exit 1
502 } 483 }
503 } && 484 } &&
504 485
505 # Now rename the file to the real destination. 486 # Now rename the file to the real destination.
506 $doit $mvcmd "$dsttmp" "$dst" 487 $doit $mvcmd "$dsttmp" "$dst"
507 } 488 }
508 fi || exit 1 489 fi || exit 1
509 490
510 trap '' 0 491 trap '' 0
511 fi 492 fi