annotate install-sh @ 112150:14a97ab281d5

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